mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-10-03 07:48:58 +02:00
added cooldown
This commit is contained in:
parent
c806a7622e
commit
0462298c44
1 changed files with 15 additions and 1 deletions
16
bot.py
16
bot.py
|
@ -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")
|
||||
@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
|
||||
if (user == None): #check if the message author submitted a different user to check, if not use the 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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def leaderboard(ctx):
|
||||
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)
|
||||
|
@ -285,6 +287,7 @@ async def leaderboard(ctx):
|
|||
# |_| |___/
|
||||
|
||||
@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
|
||||
now = datetime.utcnow()#get the current time
|
||||
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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def emoji(ctx, *message: str):#emojifies the string the user give as parameter
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
temp = ""
|
||||
|
@ -335,7 +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)")
|
||||
async def poll(ctx, question, *options: str):#this is a tool to create a poll
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user) async def poll(ctx, question, *options: str):#this is a tool to create a poll
|
||||
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
|
||||
options = list(options)
|
||||
|
@ -375,6 +379,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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def result(ctx, id):#this function prints the result of a poll
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
poll_message = polls[str(id)][0]#get the poll message from the variable
|
||||
|
@ -416,6 +421,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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def cat(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
r = get("https://api.thecatapi.com/v1/images/search?size=full") # get random cat image
|
||||
|
@ -427,6 +433,7 @@ async def cat(ctx):
|
|||
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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def dog(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
r = get("https://random.dog/woof.json") # get random dog image
|
||||
|
@ -438,6 +445,7 @@ async def dog(ctx):
|
|||
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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def fail(ctx):
|
||||
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
|
||||
|
@ -448,6 +456,7 @@ async def fail(ctx):
|
|||
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")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def jensmeme(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
r = get("https://jensmemes.tilera.xyz/api.php/random") # get random upload
|
||||
|
@ -462,6 +471,7 @@ async def jensmeme(ctx):
|
|||
#
|
||||
|
||||
@bot.command(brief="adds a song to the playlist")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def play(ctx, songURL : str):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player#import the global variables needed
|
||||
|
@ -490,6 +500,7 @@ async def play(ctx, songURL : str):
|
|||
backgroundDownloader(loads(r.text)["html"].split("src=")[1][1:].split("\"")[0], loads(r.text)["title"])
|
||||
|
||||
@bot.command(brief="skipps the current song in playlist")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def skip(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player# import the global variable
|
||||
|
@ -497,6 +508,7 @@ async def skip(ctx):
|
|||
await ctx.message.channel.send("Skipped current song")#print the status to the console
|
||||
|
||||
@bot.command(brief="Prints the current music que")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def que(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global titleQue#import the global variable
|
||||
|
@ -508,6 +520,7 @@ async def que(ctx):
|
|||
await ctx.message.channel.send(message)#send the prepared message
|
||||
|
||||
@bot.command(brief="stop the music bot and clear the que")
|
||||
@commands.cooldown(1, cooldownTime, commands.BucketType.user)
|
||||
async def stop(ctx):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player#import the global variables
|
||||
|
@ -531,6 +544,7 @@ async def stop(ctx):
|
|||
remove(files)
|
||||
|
||||
@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):
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global audioPlayer#import hte global audio player
|
||||
|
|
Loading…
Reference in a new issue