Invite command, CD on roll

This commit is contained in:
2023-05-04 21:21:45 +02:00
parent e9a8535e1c
commit 198057304f
3 changed files with 31 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
import discord
from discord.ext import commands
class Invite(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Invite.py is ready")
@commands.command()
async def invite(self, ctx):
link = "https://discord.com/api/oauth2/authorize?client_id=1100115547515011182&permissions=414464862272&scope=bot"
await ctx.send("I'm already in " + str(len(self.client.guilds)) + " servers!\n" + "Invite me now using:\n " + link)
async def setup(client):
await client.add_cog(Invite(client))
+7
View File
@@ -11,6 +11,7 @@ class Roll(commands.Cog):
print("roll.py is ready") print("roll.py is ready")
@commands.command() @commands.command()
@commands.cooldown(1, 600, commands.BucketType.user)
async def roll(self, ctx): async def roll(self, ctx):
rolled = random.randint(1,100) rolled = random.randint(1,100)
rating = "" rating = ""
@@ -38,6 +39,12 @@ class Roll(commands.Cog):
await ctx.send(message) await ctx.send(message)
@roll.error
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
time = round(error.retry_after/60)
message = f"This command is on cooldown, the cooldown ends in {time} minutes"
await ctx.send(message)
async def setup(client): async def setup(client):
await client.add_cog(Roll(client)) await client.add_cog(Roll(client))
+4 -1
View File
@@ -13,6 +13,7 @@ class Stats(commands.Cog):
@commands.command(aliases=["compare"]) @commands.command(aliases=["compare"])
async def stats(self, ctx, *message): async def stats(self, ctx, *message):
error = False
players = [] players = []
servers = [] servers = []
server = "" server = ""
@@ -21,6 +22,7 @@ class Stats(commands.Cog):
if(message == ()): if(message == ()):
await ctx.send("```No player given```") await ctx.send("```No player given```")
error = True
for i in message: for i in message:
item = i.replace(",", "") item = i.replace(",", "")
@@ -42,7 +44,8 @@ class Stats(commands.Cog):
else: else:
server = servers[0] server = servers[0]
if(len(players) == 0): if(len(players) == 0 and error == False):
error = True
await ctx.send("```No existing player found, check if the name is correct or has changed```") await ctx.send("```No existing player found, check if the name is correct or has changed```")
list_of_stats = [] list_of_stats = []