Trying an on_message function that gets disabled after the bot is fully loaded

This commit is contained in:
Logan Cusano
2022-02-18 22:43:15 -05:00
parent 54c2eeedbf
commit 57225413fc

15
bot.py
View File

@@ -27,9 +27,6 @@ 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
@@ -220,7 +217,7 @@ class Bot(commands.Bot):
await ctx.send(f"Ok {str(member).capitalize()}, I reloaded {module}")
else:
await ctx.send(f"{str(member).capitalize()}, something went wrong. Please check the console")
@self.command(name='startsdr', hidden=True)
async def _startsdr(ctx, member: discord.Member = None):
self.start_sdr()
@@ -237,12 +234,9 @@ class Bot(commands.Bot):
# 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:
if "ping" in message.content:
await self.process_commands(message)
# Check to see if other bots are online
@@ -263,12 +257,11 @@ class Bot(commands.Bot):
await channel.send(f"{self.Command_Prefix}ping")
seconds_waited = 0
while seconds_waited < 5:
while seconds_waited < 2:
try:
await self.wait_for("message", check=verify_bot_msg, timeout=1)
except asyncio.exceptions.TimeoutError:
seconds_waited += 1
print(seconds_waited)
print(f"Bots Online: {bots_online}")
@@ -372,7 +365,7 @@ class Bot(commands.Bot):
# Wait for the running processes to close
if self.Handler == 'op25':
self.OP25Handler.close_op25()
#self.OP25Handler.join()
# self.OP25Handler.join()
# Need a way to 'close' GQRX
self.sdr_started = False