1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-07-06 09:18:35 +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__/
*.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")
@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,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)")
@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
@ -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")
@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 +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")
@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 +434,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 +446,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,9 +457,10 @@ 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
r = get("https://jensmemes.tilera.xyz/api/random") # get random upload
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")
@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 +501,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):
try:
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
@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
@ -513,6 +526,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("")
try:
@ -541,6 +555,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("")
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
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
base = 10