mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-10-03 07:48:58 +02:00
added function to disable react on valid command
This commit is contained in:
parent
cf785faf0a
commit
903db4fe44
2 changed files with 15 additions and 14 deletions
28
bot.py
28
bot.py
|
@ -252,7 +252,7 @@ async def level(ctx, user : discord.Member=None):#shows your current XP and leve
|
|||
|
||||
@bot.command(brief="shows the leaderboard")
|
||||
async def leaderboard(ctx):
|
||||
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)
|
||||
|
||||
ranking = [] #to this variable we will later add the users sorted
|
||||
|
@ -287,7 +287,7 @@ async def leaderboard(ctx):
|
|||
@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
|
||||
await ctx.message.add_reaction("✅")
|
||||
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
|
||||
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
|
||||
|
||||
|
@ -304,7 +304,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")
|
||||
async def emoji(ctx, *message: str):#emojifies the string the user give as parameter
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
temp = ""
|
||||
for messages in message:#because every word will be formatted as parameter by discord.py, we have to make a long string again
|
||||
temp = temp + messages + " "
|
||||
|
@ -336,7 +336,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
|
||||
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
|
||||
options = list(options)
|
||||
options.append("yes")
|
||||
|
@ -376,7 +376,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")
|
||||
async def result(ctx, id):#this function prints the result of a poll
|
||||
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_owner = polls[str(id)][1]
|
||||
if(poll_owner != ctx.message.author.id): #check if the poll owner wants the result, or someone else
|
||||
|
@ -417,7 +417,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")
|
||||
async def cat(ctx):
|
||||
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
|
||||
answer = loads(r.text)
|
||||
extension = answer[0]["url"].split(".")[-1]#get the file extension
|
||||
|
@ -428,7 +428,7 @@ async def cat(ctx):
|
|||
|
||||
@bot.command(pass_context=True, brief="sends a random dog image")
|
||||
async def dog(ctx):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
r = get("https://random.dog/woof.json") # get random dog image
|
||||
answer = loads(r.text)
|
||||
extension = answer["url"].split(".")[-1]#get the file extension
|
||||
|
@ -439,7 +439,7 @@ async def dog(ctx):
|
|||
|
||||
@bot.command(pass_context=True, brief="sends a random fail gif")
|
||||
async def fail(ctx):
|
||||
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
|
||||
answer = loads(r.text)
|
||||
r = get(answer["data"]["images"]["downsized_medium"]["url"])#get the url to the fail
|
||||
|
@ -449,7 +449,7 @@ async def fail(ctx):
|
|||
|
||||
@bot.command(pass_context=True, brief="sends a random upload from jensmemes.tilera.xyz")
|
||||
async def jensmeme(ctx):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
r = get("https://jensmemes.tilera.xyz/randomapi.php") # get random upload
|
||||
await ctx.send(r.text)#send the fail image
|
||||
# ___ ___ _ ______ _
|
||||
|
@ -463,7 +463,7 @@ async def jensmeme(ctx):
|
|||
|
||||
@bot.command(brief="adds a song to the playlist")
|
||||
async def play(ctx, songURL : str):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player#import the global variables needed
|
||||
global playerServer
|
||||
global downloadQue
|
||||
|
@ -491,14 +491,14 @@ async def play(ctx, songURL : str):
|
|||
|
||||
@bot.command(brief="skipps the current song in playlist")
|
||||
async def skip(ctx):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player# import the global variable
|
||||
player.stop()#stop the player (daemon think song enden ==> plays next one)
|
||||
await ctx.message.channel.send("Skipped current song")#print the status to the console
|
||||
|
||||
@bot.command(brief="Prints the current music que")
|
||||
async def que(ctx):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global titleQue#import the global variable
|
||||
message = "**Musicbot Que:**\n **[current] " + titleQue[0] + " **"#prepare the message and add the current playing first in bold
|
||||
|
||||
|
@ -509,7 +509,7 @@ async def que(ctx):
|
|||
|
||||
@bot.command(brief="stop the music bot and clear the que")
|
||||
async def stop(ctx):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global player#import the global variables
|
||||
global playerQue
|
||||
global titleQue
|
||||
|
@ -532,7 +532,7 @@ async def stop(ctx):
|
|||
|
||||
@bot.command(brief="changes the volume of the music bot")#with this command you can change the volume of the music bot
|
||||
async def volume(ctx, volume : int):
|
||||
await ctx.message.add_reaction("✅")
|
||||
if reactOnValidCommand: await ctx.message.add_reaction("✅")
|
||||
global audioPlayer#import hte global audio player
|
||||
if(volume < 0) or (volume > 100):#check if the volume is in a percent range
|
||||
ctx.message.channel.send("Volume has to be between 0 and 100")
|
||||
|
|
|
@ -10,6 +10,7 @@ name="Discord" # The name of the game, stream, song, ...
|
|||
url = "" #Twitch or YouTube url of the stream
|
||||
|
||||
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
|
||||
|
||||
#leveling settings
|
||||
base = 10
|
||||
|
|
Loading…
Reference in a new issue