1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-10-05 08:48:51 +02:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Jonas Leder 2020-09-28 20:56:11 +02:00
commit c20996f463
3 changed files with 18 additions and 1 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ config.py
__pycache__/ __pycache__/
*.mp3 *.mp3
.vscode/

17
bot.py
View file

@ -198,6 +198,7 @@ async def on_voice_state_update(member, before, after):#this runs on every voice
# #
# #
@bot.command(brief="shows your current XP and level") @bot.command(brief="shows your current XP and level")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def level(ctx, user : discord.Member=None):#shows your current XP and level, as argument you can give a different user 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 if (user == None): #check if the message author submitted a different user to check, if not use the author
user = ctx.message.author user = ctx.message.author
@ -251,6 +252,7 @@ async def level(ctx, user : discord.Member=None):#shows your current XP and leve
# #
@bot.command(brief="shows the leaderboard") @bot.command(brief="shows the leaderboard")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def leaderboard(ctx): async def leaderboard(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
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) 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)
@ -285,6 +287,7 @@ async def leaderboard(ctx):
# |_| |___/ # |_| |___/
@bot.command(pass_context=True, brief="prints the ping time of the bot") @bot.command(pass_context=True, brief="prints the ping time of the bot")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def ping(ctx):#prints the ping and the time the bot needed to process this command async def ping(ctx):#prints the ping and the time the bot needed to process this command
now = datetime.utcnow()#get the current time now = datetime.utcnow()#get the current time
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
@ -303,6 +306,7 @@ async def ping(ctx):#prints the ping and the time the bot needed to process this
# |__/ |___/ # |__/ |___/
@bot.command(brief="prints the text as emojies") @bot.command(brief="prints the text as emojies")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def emoji(ctx, *message: str):#emojifies the string the user give as parameter async def emoji(ctx, *message: str):#emojifies the string the user give as parameter
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
temp = "" temp = ""
@ -335,6 +339,7 @@ async def emoji(ctx, *message: str):#emojifies the string the user give as param
# |_| # |_|
@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)") @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)")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def poll(ctx, question, *options: str):#this is a tool to create a poll async def poll(ctx, question, *options: str):#this is a tool to create a poll
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
if len(options) <= 1:#check if options were supplied, if not add yes and no to the options if len(options) <= 1:#check if options were supplied, if not add yes and no to the options
@ -375,6 +380,7 @@ async def poll(ctx, question, *options: str):#this is a tool to create a poll
# |_| # |_|
@bot.command(pass_context=True, brief="shows the result of a poll, give the poll ID as argument") @bot.command(pass_context=True, brief="shows the result of a poll, give the poll ID as argument")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def result(ctx, id):#this function prints the result of a poll async def result(ctx, id):#this function prints the result of a poll
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
poll_message = polls[str(id)][0]#get the poll message from the variable poll_message = polls[str(id)][0]#get the poll message from the variable
@ -416,6 +422,7 @@ async def result(ctx, id):#this function prints the result of a poll
# |___/ # |___/
@bot.command(pass_context=True, brief="sends a random cat image") @bot.command(pass_context=True, brief="sends a random cat image")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def cat(ctx): async def cat(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
r = get("https://api.thecatapi.com/v1/images/search?size=full") # get random cat image r = get("https://api.thecatapi.com/v1/images/search?size=full") # get random cat image
@ -427,6 +434,7 @@ async def cat(ctx):
await ctx.send(file=discord.File(image_data, 'cat.' + extension))#send the cat image await ctx.send(file=discord.File(image_data, 'cat.' + extension))#send the cat image
@bot.command(pass_context=True, brief="sends a random dog image") @bot.command(pass_context=True, brief="sends a random dog image")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def dog(ctx): async def dog(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
r = get("https://random.dog/woof.json") # get random dog image r = get("https://random.dog/woof.json") # get random dog image
@ -438,6 +446,7 @@ async def dog(ctx):
await ctx.send(file=discord.File(image_data, 'dog.' + extension))#send the dog image await ctx.send(file=discord.File(image_data, 'dog.' + extension))#send the dog image
@bot.command(pass_context=True, brief="sends a random fail gif") @bot.command(pass_context=True, brief="sends a random fail gif")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def fail(ctx): async def fail(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
r = get("https://api.giphy.com/v1/gifs/random?api_key=0UTRbFtkMxAplrohufYco5IY74U8hOes&tag=fail&pg-13") # get random fail image r = get("https://api.giphy.com/v1/gifs/random?api_key=0UTRbFtkMxAplrohufYco5IY74U8hOes&tag=fail&pg-13") # get random fail image
@ -448,9 +457,10 @@ async def fail(ctx):
await ctx.send(file=discord.File(image_data, 'fail.gif'))#send the fail image await ctx.send(file=discord.File(image_data, 'fail.gif'))#send the fail image
@bot.command(pass_context=True, brief="sends a random upload from jensmemes.tilera.xyz") @bot.command(pass_context=True, brief="sends a random upload from jensmemes.tilera.xyz")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def jensmeme(ctx): async def jensmeme(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
r = get("https://jensmemes.tilera.xyz/api.php/random") # get random upload r = get("https://jensmemes.tilera.xyz/api/random") # get random upload
await ctx.send(loads(r.text)["link"])#send the fail image await ctx.send(loads(r.text)["link"])#send the fail image
# ___ ___ _ ______ _ # ___ ___ _ ______ _
# | \/ | (_) | ___ \ | | # | \/ | (_) | ___ \ | |
@ -462,6 +472,7 @@ async def jensmeme(ctx):
# #
@bot.command(brief="adds a song to the playlist") @bot.command(brief="adds a song to the playlist")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def play(ctx, songURL : str): async def play(ctx, songURL : str):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
global player#import the global variables needed global player#import the global variables needed
@ -490,6 +501,7 @@ async def play(ctx, songURL : str):
backgroundDownloader(loads(r.text)["html"].split("src=")[1][1:].split("\"")[0], loads(r.text)["title"]) backgroundDownloader(loads(r.text)["html"].split("src=")[1][1:].split("\"")[0], loads(r.text)["title"])
@bot.command(brief="skipps the current song in playlist") @bot.command(brief="skipps the current song in playlist")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def skip(ctx): async def skip(ctx):
try: try:
channel = ctx.author.voice.channel#get the current voicechat the user is in channel = ctx.author.voice.channel#get the current voicechat the user is in
@ -502,6 +514,7 @@ async def skip(ctx):
await ctx.message.channel.send("Skipped current song")#print the status to the console await ctx.message.channel.send("Skipped current song")#print the status to the console
@bot.command(brief="Prints the current music que") @bot.command(brief="Prints the current music que")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def que(ctx): async def que(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
global titleQue#import the global variable global titleQue#import the global variable
@ -513,6 +526,7 @@ async def que(ctx):
await ctx.message.channel.send(message)#send the prepared message await ctx.message.channel.send(message)#send the prepared message
@bot.command(brief="stop the music bot and clear the que") @bot.command(brief="stop the music bot and clear the que")
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def stop(ctx): async def stop(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
try: try:
@ -541,6 +555,7 @@ async def stop(ctx):
remove(files) remove(files)
@bot.command(brief="changes the volume of the music bot")#with this command you can change the volume of the music bot @bot.command(brief="changes the volume of the music bot")#with this command you can change the volume of the music bot
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
async def volume(ctx, volume : int): async def volume(ctx, volume : int):
if reactOnValidCommand: await ctx.message.add_reaction("") if reactOnValidCommand: await ctx.message.add_reaction("")
try: try:

View file

@ -13,6 +13,7 @@ gameStartTime = 1262304000 #UNIX timestamp when the user started playing the gam
allowOnServer = [] #use this, if you want to allow this Bot only on specific Servers allowOnServer = [] #use this, if you want to allow this Bot only on specific Servers
reactOnValidCommand = True #disable this, if the bot should not react with ✅ on every valid command reactOnValidCommand = True #disable this, if the bot should not react with ✅ on every valid command
cooldownTime = 10 #time to wait until the user can execute the same command again
#leveling settings #leveling settings
base = 10 base = 10