From 496706bbb383058ce9c5748db6688a1972b3efd2 Mon Sep 17 00:00:00 2001 From: Ruan Bekker Date: Thu, 5 May 2022 12:29:45 +0200 Subject: [PATCH] Create basic_greeting_bot.py --- basic_greeting_bot.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 basic_greeting_bot.py diff --git a/basic_greeting_bot.py b/basic_greeting_bot.py new file mode 100644 index 0000000..6280dc0 --- /dev/null +++ b/basic_greeting_bot.py @@ -0,0 +1,25 @@ +import discord +import os +from dotenv import load_dotenv + +BOT_NAME = "MinecraftBot" + +load_dotenv() +DISCORD_TOKEN = os.getenv("DISCORD_TOKEN") + +bot = discord.Client() + +@bot.event +async def on_ready(): + print(f'{bot.user} has logged in.') + +@bot.event +async def on_message(message): + if message.author == bot.user: + return + if message.content == 'hello': + await message.channel.send(f'Hey {message.author}') + if message.content == 'goodbye': + await message.channel.send(f'Goodbye {message.author}') + +bot.run(DISCORD_TOKEN)