1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-08-01 15:04:39 +02:00

added big titles to the commands

This commit is contained in:
Jonas Leder 2020-04-10 14:20:40 +02:00
parent d3b46fa119
commit fdb28e30de

95
bot.py
View file

@ -24,6 +24,7 @@ try: #try to create the database tables, if it fails they were created previosly
dbcursor.execute(sql3)
except:
pass
@bot.event #print the username and id to the console and change the game status
async def on_ready():
print('Logged in as')
@ -32,6 +33,15 @@ async def on_ready():
print('------')
await bot.change_presence(activity=discord.Game(name=game))
#
#
# _ __ ___ __ __ _ __ ___ ___ ___ ___ __ _ __ _ ___
# | '_ \ / _ \\ \ /\ / / | '_ ` _ \ / _ \/ __|/ __| / _` | / _` | / _ \
# | | | || __/ \ V V / | | | | | || __/\__ \\__ \| (_| || (_| || __/
# |_| |_| \___| \_/\_/ |_| |_| |_| \___||___/|___/ \__,_| \__, | \___|
# __/ |
# |___/
@bot.event
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
@ -53,6 +63,15 @@ async def on_message(message):#this will run on every message
if (message.content[:3] == "hi ") or (message.content[-3:] == " hi"):
await message.channel.send("Hello <@!" + str(message.author.id) + "> To get a list of my commands enter " + prefix + "help.")
# _ _ _ _
# | | (_) | | | |
# _ __ ___ __ _ ___ | |_ _ ___ _ __ __ _ __| | __| |
# | '__| / _ \ / _` | / __|| __|| | / _ \ | '_ \ / _` | / _` | / _` |
# | | | __/| (_| || (__ | |_ | || (_) || | | | | (_| || (_| || (_| |
# |_| \___| \__,_| \___| \__||_| \___/ |_| |_| \__,_| \__,_| \__,_|
#
#
@bot.event
async def on_raw_reaction_add(message): #this runs on every reaction
if(message.user_id == bot.user.id):#check if the bot has written the message, if yes stop parsing it
@ -74,6 +93,15 @@ async def on_raw_reaction_add(message): #this runs on every reaction
pass
dbconnection.commit() #write the database changes to disk
# _ _
# | | (_)
# _ __ ___ __ _ ___ | |_ _ ___ _ __ _ __ ___ _ __ ___ ___ __ __ ___
# | '__| / _ \ / _` | / __|| __|| | / _ \ | '_ \ | '__| / _ \| '_ ` _ \ / _ \ \ \ / / / _ \
# | | | __/| (_| || (__ | |_ | || (_) || | | | | | | __/| | | | | || (_) | \ V / | __/
# |_| \___| \__,_| \___| \__||_| \___/ |_| |_| |_| \___||_| |_| |_| \___/ \_/ \___|
#
#
@bot.event
async def on_raw_reaction_remove(message):
@ -85,6 +113,15 @@ async def on_raw_reaction_remove(message):
pass
dbconnection.commit()# write the database changes to disk
# _ _ _ _ _
# (_) | | | | | | | |
# __ __ ___ _ ___ ___ ___ | |__ __ _ | |_ _ _ _ __ __| | __ _ | |_ ___
# \ \ / / / _ \ | | / __| / _ \ / __|| '_ \ / _` || __| | | | || '_ \ / _` | / _` || __| / _ \
# \ V / | (_) || || (__ | __/| (__ | | | || (_| || |_ | |_| || |_) || (_| || (_| || |_ | __/
# \_/ \___/ |_| \___| \___| \___||_| |_| \__,_| \__| \__,_|| .__/ \__,_| \__,_| \__| \___|
# | |
# |_|
@bot.event
async def on_voice_state_update(member, before, after):#this runs on every voice chat update (user joins, leaves, go afk, moves, ...)
if member.bot or (member.id == bot.user.id): #check if the bot is the user, if yes stop parsing it
@ -117,7 +154,14 @@ async def on_voice_state_update(member, before, after):#this runs on every voice
dbcursor.execute("INSERT INTO VcActive VALUES (?, ?)", [member.id, round(time())])#insert the current time in the database
dbconnection.commit()#write the changes to databasr
return
# _ _
# | | | |
# | | ___ __ __ ___ | |
# | | / _ \\ \ / / / _ \| |
# | || __/ \ V / | __/| |
# |_| \___| \_/ \___||_|
#
#
@bot.command(brief="shows your current XP and level")
async def level(ctx, user : discord.Member=None):#shows your current XP and level, as argument you can give a different user
if (user == None): #check if the message author submitted a different user to check, if not use the author
@ -162,6 +206,15 @@ async def level(ctx, user : discord.Member=None):#shows your current XP and leve
await ctx.message.channel.send(embed=embed) #send the response message
# _ _ _ _
# | | | | | | | |
# | | ___ __ _ __| | ___ _ __ | |__ ___ __ _ _ __ __| |
# | | / _ \ / _` | / _` | / _ \| '__|| '_ \ / _ \ / _` || '__| / _` |
# | || __/| (_| || (_| || __/| | | |_) || (_) || (_| || | | (_| |
# |_| \___| \__,_| \__,_| \___||_| |_.__/ \___/ \__,_||_| \__,_|
#
#
@bot.command(brief="shows the leaderboard")
async def leaderboard(ctx):
unsorted = dbcursor.execute("SELECT user, textXP, reactionXP, vcXP FROM MESSAGES WHERE server = ?", [ctx.message.guild.id]).fetchall() #get all users from the database (for the ranking)
@ -186,6 +239,15 @@ async def leaderboard(ctx):
embed = discord.Embed(title="Leaderboard" , description=message)#make the response Box
await ctx.message.channel.send(embed=embed)#print the ressponse box
# _
# (_)
# _ __ _ _ __ __ _
# | '_ \ | || '_ \ / _` |
# | |_) || || | | || (_| |
# | .__/ |_||_| |_| \__, |
# | | __/ |
# |_| |___/
@bot.command(pass_context=True, brief="prints the ping time of the bot")
async def ping(ctx):#prints the ping and the time the bot needed to process this command
now = datetime.utcnow()#get the current time
@ -194,6 +256,15 @@ async def ping(ctx):#prints the ping and the time the bot needed to process this
await ctx.message.channel.send(embed=embed)#send the prepared message
# _ _ __ _ _
# (_)(_) / _| | | | |
# ___ _ __ ___ ___ _ _ | |_ _ _ | |_ ___ __ __| |_
# / _ \| '_ ` _ \ / _ \ | || || _|| | | | | __| / _ \\ \/ /| __|
# | __/| | | | | || (_) | | || || | | |_| | | |_ | __/ > < | |_
# \___||_| |_| |_| \___/ | ||_||_| \__, | \__| \___|/_/\_\ \__|
# _/ | __/ |
# |__/ |___/
@bot.command(brief="prints the text as emojies")
async def emoji(ctx, *message: str):#emojifies the string the user give as parameter
temp = ""
@ -215,6 +286,16 @@ async def emoji(ctx, *message: str):#emojifies the string the user give as param
messageNew = messageNew + char
await ctx.message.channel.send(messageNew)#send the formatted message
# _ _
# | || |
# _ __ ___ | || |
# | '_ \ / _ \ | || |
# | |_) || (_) || || |
# | .__/ \___/ |_||_|
# | |
# |_|
@bot.command(pass_context=True, brief="starts a poll", description="starts a poll, please give as first argument the question (for sentences please use \") and then the posibilities (leave empty for yes or no)")
async def poll(ctx, question, *options: str):#this is a tool to create a poll
if len(options) <= 1:#check if options were supplied, if not add yes and no to the options
@ -245,6 +326,15 @@ async def poll(ctx, question, *options: str):#this is a tool to create a poll
embed.set_footer(text='Poll ID: {}'.format(react_message.id))#add the poll id to the message (needed to get the results)
await react_message.edit(embed=embed)
# _ _ _ _
# | || | | || |
# _ __ ___ | || | _ __ ___ ___ _ _ | || |_
# | '_ \ / _ \ | || | | '__| / _ \/ __|| | | || || __|
# | |_) || (_) || || | | | | __/\__ \| |_| || || |_
# | .__/ \___/ |_||_| |_| \___||___/ \__,_||_| \__|
# | |
# |_|
@bot.command(pass_context=True, brief="shows the result of a poll, give the poll ID as argument")
async def result(ctx, id):#this function prints the result of a poll
poll_message = polls[str(id)]#get the poll message from the variable
@ -271,4 +361,7 @@ async def result(ctx, id):#this function prints the result of a poll
dbcursor.execute("DELETE FROM poll where pollID = ?", [id])#delete the entries from the poll in the database
dbconnection.commit()#write the database to disk
bot.run(token, bot=botAccount)#start the bot with the options in config.py