diff --git a/main.py b/main.py index daec325..d049445 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,14 @@ -import asyncio import discord -from discord.ext import commands import sys, traceback -import aiohttp -import json import mysql.connector from botClient import client, botToken, dbuser, dbpasswd +"""Select the modules to load""" extensions = ['basicFunctionsFile', 'adminFunctionsFile', 'helpFile', 'gameFunctionsFile', - 'apiFunctionsFile'] + 'apiFunctionsFile', 'imageSearchFunctionsFile', + 'musicPlayerFile', 'commandErrorHandlerFile'] +"""Attempt connection to the MySQL database""" try: #try to connect to the MySQL database mydb= mysql.connector.connect( host ="localhost", @@ -23,11 +22,11 @@ try: #try to connect to the My for x in mycursor: print(x) -except mysql.connector.errors.InterfaceError as error: #if bot can't connect to db (maybe it's offline) - print(f"Can't establish connection to database. Error details: ({error})") - +except mysql.connector.errors.InterfaceError as error: #if bot can't connect to db (e.g it's offline) + print(error) +"""Confirms the bot is ready""" @client.event async def on_ready(): print('-----------------------') @@ -35,8 +34,12 @@ async def on_ready(): print(client.user.name) print('CID: ' + str(client.user.id)) print('-----------------------') + """Sets the bot status message on Discord""" + text = discord.Game(">comhelp | Waiting for rA9") + await client.change_presence(status=discord.Status.online, activity=text) -if __name__ == '__main__': #Load extensions from other modules +"""Load the modules selected above in the extensions""" +if __name__ == '__main__': for extension in extensions: try: client.load_extension(extension) @@ -46,19 +49,10 @@ if __name__ == '__main__': #Load extensions from other modules @client.event async def on_message(message): + """So that the bot doesn't reply to itself.""" if message.author.id == client.user.id: return await client.process_commands(message) #So that events don't disable commands -@client.event -async def on_member_join(member): - await message.channel.send(f'Welcome {member.mention} to {member.guild.name}!') - await client.process_commands(message) #So that events don't disable commands - -@client.command() -async def ctest(ctx): - await ctx.send('I heard you! {}'.format(ctx.author.mention)) - - client.run(botToken)