diff --git a/cogs/GetInfo.py b/cogs/GetInfo.py index e4a1b6ab..5e959548 100644 --- a/cogs/GetInfo.py +++ b/cogs/GetInfo.py @@ -16,8 +16,9 @@ class GetInfo(commands.Cog): # ~userinfo to allow the users to see information about them relating to the guild @command(name="userinfo", aliases=["ui"]) - @cooldown(1, 1, BucketType.user) + @cooldown(1, 5, BucketType.user) async def user_info(self, ctx, target: Optional[Member]): + # If a target has been specified, set them as the user if target: target = target @@ -82,53 +83,50 @@ class GetInfo(commands.Cog): # Send the embed to the channel that the command was triggered in await ctx.send(embed=embed) + # ~serverinfo to allow the users to see information the guild itself @command(name="serverinfo", aliases=["guildinfo"]) - @cooldown(1, 1, BucketType.user) + @cooldown(1, 5, BucketType.user) async def server_info(self, ctx): - try: - # Define guild icon and id - guild_icon = ctx.guild.icon_url - guild_id = ctx.guild.id - - # Define the statuses of the members within the discord - statuses = [len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members))), - len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members))), - len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members))), - len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))] - - # Set up embed to display all the server information - embed = Embed(title="**Server Information**", - colour=Colour(int(random.choice(settings.colour_list))), - timestamp=datetime.datetime.utcnow()) - embed.set_thumbnail(url=guild_icon) - embed.set_footer(text=f"ID: {guild_id}", icon_url='{}'.format(guild_icon)) - - # Define fields to be added into the embed - fields = [("Owner", ctx.guild.owner, True), - ("Created", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), False), - ("Region", str(ctx.guild.region).upper(), False), - ("Statuses", f"🟢 {statuses[0]} 🟠 {statuses[1]} 🔴 {statuses[2]} ⚪ {statuses[3]}", False), - ("\u200b", "\u200b", False), - ("Members", len(ctx.guild.members), True), - ("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True), - ("Bots", len(list(filter(lambda c: c.bot, ctx.guild.members))), True), - ("Banned Members", len(await ctx.guild.bans()), True), - ("Text Channels", len(ctx.guild.text_channels), True), - ("Voice Channels", len(ctx.guild.voice_channels), True), - ("Categories", len(ctx.guild.categories), True), - ("Roles", len(ctx.guild.roles), True), - ("Invites", len(await ctx.guild.invites()), True)] - - # Add fields to the embed - for name, value, inline in fields: - embed.add_field(name=name, value=value, inline=inline) - - # Send the embed to the channel that the command was triggered in - await ctx.send(embed=embed) - - except Exception as ex: - print(ex) + # Define guild icon and id + guild_icon = ctx.guild.icon_url + guild_id = ctx.guild.id + + # Define the statuses of the members within the discord + statuses = [len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members))), + len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members))), + len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members))), + len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))] + + # Set up embed to display all the server information + embed = Embed(title="**Server Information**", + colour=Colour(int(random.choice(settings.colour_list))), + timestamp=datetime.datetime.utcnow()) + embed.set_thumbnail(url=guild_icon) + embed.set_footer(text=f"ID: {guild_id}", icon_url='{}'.format(guild_icon)) + + # Define fields to be added into the embed + fields = [("Owner", ctx.guild.owner, True), + ("Created", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), False), + ("Region", str(ctx.guild.region).upper(), False), + ("Statuses", f"🟢 {statuses[0]} 🟠 {statuses[1]} 🔴 {statuses[2]} ⚪ {statuses[3]}", False), + ("\u200b", "\u200b", False), + ("Members", len(ctx.guild.members), True), + ("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True), + ("Bots", len(list(filter(lambda c: c.bot, ctx.guild.members))), True), + ("Banned Members", len(await ctx.guild.bans()), True), + ("Text Channels", len(ctx.guild.text_channels), True), + ("Voice Channels", len(ctx.guild.voice_channels), True), + ("Categories", len(ctx.guild.categories), True), + ("Roles", len(ctx.guild.roles), True), + ("Invites", len(await ctx.guild.invites()), True)] + + # Add fields to the embed + for name, value, inline in fields: + embed.add_field(name=name, value=value, inline=inline) + + # Send the embed to the channel that the command was triggered in + await ctx.send(embed=embed) def setup(bot):