Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-instant-1· AnthropicHugging Face Arena Human Preference 55K

code for a basic discord bot with commands hello, ping, and dice

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with vicuna-7b’s answer.
  1. User

    code for a basic discord bot with commands hello, ping, and dice

  2. Claude Assistant

    Here is code for a basic Discord bot with hello, ping and dice commands:

    import discord
    from discord.ext import commands
    
    client = commands.Bot(command_prefix = '!')
    
    @client.event
    async def on_ready():
        print('Bot is ready!')
    
    @client.command()
    async def hello(ctx):
        await ctx.send('Hello!')
    
    @client.command()
    async def ping(ctx):
        await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
    
    @client.command() 
    async def dice(ctx):
        await ctx.send(str(random.randint(1, 6)))
    
    client.run('your bot token here')
    

    This does the following:

    • Imports the discord and discord.ext.commands libraries
    • Creates a Bot instance with ! as the command prefix
    • Handles the on_ready event to print when the bot is ready
    • Defines the !hello command to respond with "Hello!"
    • Defines the !ping command to respond with "Pong!" and the bot latency
    • Defines the !dice command to roll a random number from 1 to 6 and send that result
    • Runs the bot using your bot token

    The bot token can be obtained by creating a bot application on the Discord Developer Portal. Hope this helps! Let me know if you have any other questions.

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

Identical first prompt