diff --git a/main.py b/main.py index 480493f..8ebce0c 100644 --- a/main.py +++ b/main.py @@ -2,14 +2,35 @@ import discord from discord.ext import commands import sys, traceback -from botClient import client -from botClient import botToken -import guessFile +import aiohttp +import json +import mysql.connector +from botClient import client, botToken, dbuser, dbpasswd + +extensions = ['test', 'basicFunctionsFile', 'adminFunctionsFile', 'helpFile', 'gameFunctionsFile', + 'apiFunctionsFile'] + +try: #try to connect to the MySQL database + mydb= mysql.connector.connect( + host ="localhost", + user = dbuser, + passwd = dbpasswd, + database = "testdatabase" + ) + print('Successfully connected to the MySQL database.') + mycursor = mydb.cursor() + # mycursor.execute("SHOW DATABASES") + + 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})") + -extensions = ['test', 'basicFunctionsFile', 'helpFile', 'guessFile'] #Extensions list @client.event async def on_ready(): + print('-----------------------') print('Logged in as') print(client.user.name) print('CID: ' + str(client.user.id)) @@ -25,19 +46,15 @@ async def on_ready(): @client.event async def on_message(message): - if message.author == client.user: + if message.author.id == client.user.id: return + await client.process_commands(message) #So that events don't disable commands - if message.content == 'hai': - await message.channel.send('YES') - - await client.process_commands(message) #So that events don't disable commands @client.event async def on_member_join(member): - # print(ctx.author.guild.name) testing await message.channel.send(f'Welcome {member.mention} to {member.guild.name}!') - await client.process_commands(message) #So that events don't disable commands + await client.process_commands(message) #So that events don't disable commands @client.command() async def ctest(ctx): @@ -45,4 +62,3 @@ async def ctest(ctx): client.run(botToken) -