mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-05-21 06:25:58 +02:00
cleanup
This commit is contained in:
parent
78fd8d533a
commit
b6bb7b3a54
16
bot.py
16
bot.py
|
@ -27,7 +27,7 @@ bot = commands.Bot(command_prefix=prefix)
|
|||
dbconnection = connect('database.db')
|
||||
dbcursor = dbconnection.cursor()
|
||||
|
||||
try: # try to create the database tables, if it fails they were created previosly
|
||||
try: # try to create the database tables, if it fails they were created previously
|
||||
sql = "CREATE TABLE MESSAGES(user LONG, server LONG, textXP LONG, reactionXP LONG, vcXP LONG)"
|
||||
sql2 = "CREATE TABLE VcActive (user LONG, startTime LONG)"
|
||||
sql3 = "CREATE TABLE poll (pollID LONG, reaction STRING, calls LONG)"
|
||||
|
@ -44,13 +44,13 @@ async def on_ready():
|
|||
print(bot.user.name)
|
||||
print(bot.user.id)
|
||||
print('------')
|
||||
if (activity == 0):
|
||||
if activity == 0:
|
||||
await bot.change_presence(activity=discord.Game(name=name, start=datetime.fromtimestamp(gameStartTime)))
|
||||
if (activity == 1):
|
||||
if activity == 1:
|
||||
await bot.change_presence(activity=discord.Streaming(name=name, url=url))
|
||||
if (activity == 2):
|
||||
if activity == 2:
|
||||
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=name))
|
||||
if (activity == 3):
|
||||
if activity == 3:
|
||||
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=name))
|
||||
|
||||
|
||||
|
@ -80,14 +80,14 @@ async def on_message(message): # this will run on every message
|
|||
print(
|
||||
str(message.author) + " sent: " + str(message.content) + ", latency: " + str(bot.latency) + " ms, Bot: " + str(
|
||||
message.author.bot)) # print some information about the message to the console
|
||||
if (message.author.bot) or (
|
||||
if message.author.bot or (
|
||||
message.author.id == bot.user.id): # check if the bot has written the message, if yes stop parsing it
|
||||
return
|
||||
try:
|
||||
res = dbcursor.execute("SELECT textXP FROM MESSAGES WHERE user=? AND server = ?",
|
||||
[message.author.id, message.guild.id]) # try to get the current textXP of the user
|
||||
result = res.fetchone()
|
||||
if (result == None):
|
||||
if result == None:
|
||||
dbcursor.execute("INSERT INTO MESSAGES VALUES (?, ?, ?, 0, 0)", [message.author.id, message.guild.id,
|
||||
messageXP]) # if Bot can't find the user in the Database create a new entry
|
||||
else:
|
||||
|
@ -340,7 +340,7 @@ async def ping(ctx): # prints the ping and the time the bot needed to process t
|
|||
now = datetime.utcnow() # get the current time
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
delta = round((
|
||||
now.microsecond - ctx.message.created_at.microsecond) / 1000) # substract the time the message was created from the current time 8in microsecconds), convert this to millisecconds and round
|
||||
now.microsecond - ctx.message.created_at.microsecond) / 1000) # substract the time the message was created from the current time 8in microsecconds), convert this to millisecconds and round
|
||||
embed = discord.Embed(title=":ping_pong: | Pong!", description="```prolog\nLatency:: " + str(
|
||||
round(bot.latency * 1000)) + "ms\nResponse :: " + str(
|
||||
delta) + "ms```") # make the response, we format it as code and select prolog as language for nice cloloring
|
||||
|
|
Loading…
Reference in a new issue