From 54c2eeedbff4d04b8adbfefcc52b6190673c5af2 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Fri, 18 Feb 2022 22:34:47 -0500 Subject: [PATCH] Trying an on_message function that gets disabled after the bot is fully loaded --- bot.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 80977cf..4259566 100644 --- a/bot.py +++ b/bot.py @@ -27,6 +27,9 @@ class Bot(commands.Bot): self.Handler = kwargs['Handler'] self.Command_Prefix = kwargs['command_prefix'] + # Init variable to check if startup has completed + self.Startup_Complete = False + # Init Variable for sound self.streamHandler = None @@ -69,7 +72,6 @@ class Bot(commands.Bot): async def ping(ctx): if ctx.author.id != self.user.id: await ctx.send('pong') - await self.process_commands(ctx) # Command to join the bot the voice channel the user who called the command is in @self.command(help="Use this command to join the bot to your channel", @@ -229,11 +231,20 @@ class Bot(commands.Bot): # Add discord events to the bot def add_events(self): + # Run any functions that need to have the bot running to complete @self.event async def on_ready(): # Check the ./modules folder for any modules (cog.py) await self.check_for_modules() + # Set the startup completed variable as true + self.Startup_Complete = True + + @self.event + async def on_message(message): + if not self.Startup_Complete: + await self.process_commands(message) + # Check to see if other bots are online async def check_other_bots_online(self): print('Checking if other bots are online')