From f7ca997c96714fae5a3e0b970d435e518413ea68 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 7 Aug 2024 22:45:23 +0100 Subject: [PATCH] Implement a basic bot with a single hello command --- matchy.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/matchy.py b/matchy.py index 40a2020..6477cf4 100644 --- a/matchy.py +++ b/matchy.py @@ -1,22 +1,18 @@ # This example requires the 'message_content' intent. import discord +import os +import logging +from discord.ext import commands intents = discord.Intents.default() intents.message_content = True -client = discord.Client(intents=intents) +bot = commands.Bot(command_prefix='$', description="test", intents=intents) -@client.event -async def on_ready(): - print(f'We have logged in as {client.user}') +@bot.command() +async def hello(ctx, *args): + """Just say hello back""" + await ctx.send(f"Hi {ctx.author.mention}") -@client.event -async def on_message(message): - if message.author == client.user: - return - - if message.content.startswith('$hello'): - await message.channel.send('Hello!') - -client.run('your token here') \ No newline at end of file +bot.run(os.getenv("BOT_TOKEN")) \ No newline at end of file