Trying an on_message function that gets disabled after the bot is fully loaded
This commit is contained in:
13
bot.py
13
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')
|
||||
|
||||
Reference in New Issue
Block a user