Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

Write me a skeleton discord bot in python using discord.py

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    Write me a skeleton discord bot in python using discord.py

  2. Assistant

    Sure, here's a skeleton Discord bot in Python using the discord.py library:

    import discord
    from discord.ext import commands
    
    bot = commands.Bot(command_prefix='!')
    
    @bot.event
    async def on_ready():
        print(f'{bot.user.name} has connected to Discord!')
    
    @bot.command(name='ping')
    async def ping(ctx):
        await ctx.send('Pong!')
    
    bot.run('<your-bot-token>')
    

    This code sets up a basic Discord bot that responds with "Pong!" when a user sends the command !ping. To use this code, you'll need to replace <your-bot-token> with your actual bot token.

    Once you have the code saved as a Python file, you can run it from the command line or terminal using:

    python3 <filename>.py
    

    Make sure that you have installed the discord.py library by running pip install discord.py beforehand.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.