[python] Discord Bot
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- import discord
- from keep_alive import keep_alive
- from discord.ext import commands
- from discord import app_commands
- import random
- from random import random
- import math
- intents = discord.Intents.default()
- client = commands.Bot(intents = intents, command_prefix = '.')
- keep_alive()
- @client.event
- async def on_ready():
- await client.tree.sync(guild=discord.Object(id=849710808087003176))
- print("Ready!")
- @app_commands.command(name ='jerkdmg', description = 'Calculate the amount of damage jerks deal to you when you fight against them in-game.')
- async def jerkdamage(ctx, jerkTotal: int, strength: int, additionalStrength: int, armor: int):
- try:
- data = []
- jerkTotal = jerkTotal
- strength = strength
- additionalStrength = additionalStrength
- armor = armor
- if int(jerkTotal)>10000 or int(strength)>25000 or int(additionalStrength)>5000 or int(armor)>5000:
- await ctx.send("Don't break me with unreasonable values!")
- return
- count = 0
- totaljerkDam = 0
- strength = float(int(strength))
- additionalStrength = float(int(additionalStrength))
- armor = float(int(armor))
- for i in range(0,1000):
- jerkDam = 0
- for i in range(0,int(jerkTotal)):
- if (armor + (random()*(strength+additionalStrength)))<float(jerkTotal):
- jerkDam+= math.floor(random()*4+1)
- count+=1
- totaljerkDam+= jerkDam
- data.append(jerkDam)
- data.sort()
- await ctx.send(str(totaljerkDam/count) + " is the average damage that Derek would sustain per round, assuming that number of jerks = " + str(jerkTotal) + ", strength = " + str(strength) + ", additional strength = " + str(additionalStrength) + ", and armor = " + str(armor) + ". This damage can be off by around 1% at the most because this runs the damage calculation 1000 times. There is a 95% chance that the damage done to the jerk is below or equal to " + str(data[949]) + ". This is also subject to some deviations due to the same reason as the average damage calculation.")
- except:
- await ctx.send("An error occurred. Make sure you put in the right values: \n jerkdmg <jerk total> <strength> <additionalStrength> <armor>, where all the parameters are whole numbers.")
- @app_commands.command(name ='ping', description = 'returns pong')
- async def ping(ctx):
- await ctx.send('Pong! '+ str(round(client.latency*1000, 1)) + " ms")
- @app_commands.command(name ='pong', description = 'returns ping')
- async def pong(ctx):
- await ctx.send('Ping! '+ str(round(client.latency*1000, 1)) + " ms")
- @app_commands.command(name = 'froggy', description = 'froggy quotes!')
- async def froggy(ctx):
- a = random()*6
- if a<1:
- await ctx.send("Infinicycle or death! - Froggy Henry")
- elif a<2:
- await ctx.send("All hail infinicycle! - Lord of the Fet")
- elif a<3:
- await ctx.send("I dealt 10^879 damage to the Dereks! And nobody can beat me! Hahahahaha! - Lord of the Fet")
- elif a<4:
- await ctx.send("It's common sense to use infinicycle over throwing jerks. - Froggy Paine")
- elif a<5:
- await ctx.send("Eureka! I combined BOTH of our strategies, for INFINITE CYCLE ***FAT JERK*** destruciton!!!! - Froggymedes")
- else:
- await ctx.send("WAIT WHAT ......... VENGEFUL!?!??!?!?!? THe vengelful barely does any damage, and is reset after each jerk cycle ,and thus is ruled obsleete. But the cocach stays forever!!!!1\nandthe tradeoff for jerk actions... just isn't good - Triggered Froggy")
- client.remove_command("help")
- @app_commands.command(name = 'help', description = 'help')
- async def help(ctx):
- embedVar = discord.Embed(title="Help", description="Here's some help with commands. ", color=0x00ff00)
- embedVar.add_field(name="help", value="This!", inline=False)
- embedVar.add_field(name="jerkdmg", value="Returns average jerk damage.", inline=False)
- embedVar.add_field(name="ping", value="Returns ping.", inline=False)
- embedVar.add_field(name="froggy", value="Froggy quotes!", inline=False)
- await ctx.send(embed = embedVar)
- with open("token.txt") as f:
- token = [line.strip() for line in f.readlines()][0]
- client.run(token)
Editor
You can edit this paste and save as new: