From 198057304fe123f6523d131529d706ead86b9e11 Mon Sep 17 00:00:00 2001 From: iiLarsH Date: Thu, 4 May 2023 21:21:45 +0200 Subject: [PATCH] Invite command, CD on roll --- cogs/invite.py | 20 ++++++++++++++++++++ cogs/roll.py | 7 +++++++ cogs/stats.py | 5 ++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 cogs/invite.py diff --git a/cogs/invite.py b/cogs/invite.py new file mode 100644 index 0000000..3a82007 --- /dev/null +++ b/cogs/invite.py @@ -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)) \ No newline at end of file diff --git a/cogs/roll.py b/cogs/roll.py index 2255dd3..3edab7a 100644 --- a/cogs/roll.py +++ b/cogs/roll.py @@ -11,6 +11,7 @@ class Roll(commands.Cog): print("roll.py is ready") @commands.command() + @commands.cooldown(1, 600, commands.BucketType.user) async def roll(self, ctx): rolled = random.randint(1,100) rating = "" @@ -38,6 +39,12 @@ class Roll(commands.Cog): 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): await client.add_cog(Roll(client)) \ No newline at end of file diff --git a/cogs/stats.py b/cogs/stats.py index 32810fd..2130f37 100644 --- a/cogs/stats.py +++ b/cogs/stats.py @@ -13,6 +13,7 @@ class Stats(commands.Cog): @commands.command(aliases=["compare"]) async def stats(self, ctx, *message): + error = False players = [] servers = [] server = "" @@ -21,6 +22,7 @@ class Stats(commands.Cog): if(message == ()): await ctx.send("```No player given```") + error = True for i in message: item = i.replace(",", "") @@ -42,7 +44,8 @@ class Stats(commands.Cog): else: 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```") list_of_stats = []