diff options
Diffstat (limited to 'cogs')
-rwxr-xr-x | cogs/admin.py | 10 | ||||
-rw-r--r-- | cogs/errorhandler.py | 11 | ||||
-rwxr-xr-x | cogs/general.py | 52 | ||||
-rwxr-xr-x | cogs/logs.py | 4 | ||||
-rwxr-xr-x | cogs/player.py | 22 | ||||
-rwxr-xr-x | cogs/src.py | 4 | ||||
-rwxr-xr-x | cogs/trans.py | 4 | ||||
-rwxr-xr-x | cogs/twitter.py | 4 | ||||
-rwxr-xr-x | cogs/utils.py | 27 | ||||
-rwxr-xr-x | cogs/webserver.py | 4 |
10 files changed, 62 insertions, 80 deletions
diff --git a/cogs/admin.py b/cogs/admin.py index 2306382..8adfe83 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -64,7 +64,7 @@ class Admin(commands.Cog): async def _reload(self, ctx, ext): """Reloads an extension""" try: - self.bot.reload_extension(f"cogs.{ext}") + await self.bot.reload_extension(f"cogs.{ext}") await ctx.send(f"The extension {ext} was reloaded!") except commands.ExtensionNotFound: await ctx.send(f"The extension {ext} doesn't exist.") @@ -85,7 +85,7 @@ class Admin(commands.Cog): async def _load(self, ctx, ext): """Loads an extension""" try: - self.bot.load_extension(f"cogs.{ext}") + await self.bot.load_extension(f"cogs.{ext}") await ctx.send(f"The extension {ext} was loaded!") except commands.ExtensionNotFound: await ctx.send(f"The extension {ext} doesn't exist!") @@ -106,7 +106,7 @@ class Admin(commands.Cog): async def _unload(self, ctx, ext): """Loads an extension""" try: - self.bot.unload_extension(f"cogs.{ext}") + await self.bot.unload_extension(f"cogs.{ext}") await ctx.send(f"The extension {ext} was unloaded!") except commands.ExtensionNotFound: await ctx.send(f"The extension {ext} doesn't exist!") @@ -353,5 +353,5 @@ class Admin(commands.Cog): await ctx.send("Something went wrong") -def setup(bot): - bot.add_cog(Admin(bot)) +async def setup(bot): + await bot.add_cog(Admin(bot)) diff --git a/cogs/errorhandler.py b/cogs/errorhandler.py index d428d72..0b61e7d 100644 --- a/cogs/errorhandler.py +++ b/cogs/errorhandler.py @@ -56,13 +56,6 @@ class Errorhandler(commands.Cog): f"{ctx.author.mention}, you have to wait {round(error.retry_after, 2)} seconds before using this again" ) - # For this error example we check to see where it came from... - elif isinstance(error, commands.BadArgument): - if ( - ctx.command.qualified_name == "tag list" - ): # Check if the command being invoked is 'tag list' - await ctx.send("I could not find that member. Please try again.") - else: # All other Errors not returned come here. And we can just print the default TraceBack. print( @@ -73,5 +66,5 @@ class Errorhandler(commands.Cog): ) -def setup(bot): - bot.add_cog(Errorhandler(bot)) +async def setup(bot): + await bot.add_cog(Errorhandler(bot)) diff --git a/cogs/general.py b/cogs/general.py index cbda1c9..8f9e680 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -428,10 +428,13 @@ class General(commands.Cog): else:
color = user.color
- if user.is_avatar_animated():
- profilePic = user.avatar_url_as(format="gif")
+ if user.avatar:
+ if user.avatar.is_animated():
+ profilePic = user.avatar.replace(format="gif")
+ else:
+ profilePic = user.avatar.replace(format="png")
else:
- profilePic = user.avatar_url_as(format="png")
+ profilePic = None
embed = discord.Embed(
title=user.name,
@@ -442,7 +445,10 @@ class General(commands.Cog): if user.premium_since:
embed.add_field(name="Boosting since", value=user.premium_since.date())
# embed.set_thumbnail(url="attachment://temp.webp")
- embed.set_thumbnail(url=profilePic)
+ if profilePic:
+ embed.set_thumbnail(url=profilePic)
+ else:
+ embed.set_thumbnail(url=user.default_avatar.replace(format="png"))
embed.add_field(name="Nickname", value=user.display_name, inline=False)
embed.add_field(name="Joined on", value=user.joined_at.date(), inline=True)
embed.add_field(name="Status", value=user.status, inline=True)
@@ -475,7 +481,7 @@ class General(commands.Cog): await ctx.send("You are now in the coop gang")
@commands.command()
- async def serverinfo(self, ctx, guild=None):
+ async def serverinfo(self, ctx, guild: discord.Guild = None):
"""Get information about the server you are in"""
if not guild:
guild = ctx.message.guild
@@ -490,12 +496,15 @@ class General(commands.Cog): emojiList = " "
for i in guild.emojis:
- emojiList += str(i) + " "
+ emojiList += str(i)
- if guild.is_icon_animated():
- serverIcon = guild.icon_url_as(format="gif")
+ if guild.icon:
+ if guild.icon.is_animated():
+ serverIcon = guild.icon.replace(format="gif")
+ else:
+ serverIcon = guild.icon.replace(format="png")
else:
- serverIcon = guild.icon_url_as(format="png")
+ serverIcon = None
inactiveMembers = await guild.estimate_pruned_members(days=7)
@@ -508,25 +517,20 @@ class General(commands.Cog): if guild.premium_subscription_count == 0:
pass
else:
- if guild.premium_subscription_count == 1:
- embed.add_field(
- name="Amount of boosts:",
- value=f"{guild.premium_subscription_count} boost",
- inline=True,
- )
- else:
- embed.add_field(
- name="Amount of boosts:",
- value=f"{guild.premium_subscription_count} boosts",
- inline=True,
- )
+ embed.add_field(
+ name="Amount of boosts:",
+ value=f"{guild.premium_subscription_count} boost{'s' if guild.premium_subscription_count != 1 else ''}",
+ inline=True,
+ )
+
if guild.premium_subscribers:
boosters = ""
for i in guild.premium_subscribers:
boosters += i.mention + " "
embed.add_field(name="Boosted by:", value=boosters, inline=True)
embed.set_thumbnail(url=serverIcon)
- embed.set_image(url=guild.splash_url_as(format="png"))
+ if guild.splash:
+ embed.set_image(url=guild.splash.replace(format="png"))
embed.add_field(name="Created on", value=guild.created_at.date(), inline=True)
embed.add_field(name="Members", value=guild.member_count, inline=True)
# embed.add_field(name="Emojis", value=emojiList, inline=True)
@@ -738,5 +742,5 @@ class General(commands.Cog): await ctx.send(f"```json\n{json.dumps(response, indent=4)}```")
-def setup(bot):
- bot.add_cog(General(bot))
+async def setup(bot):
+ await bot.add_cog(General(bot))
diff --git a/cogs/logs.py b/cogs/logs.py index 9912d63..58d9416 100755 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -52,5 +52,5 @@ class Logs(commands.Cog): await channel.send(embed=embed) -def setup(bot): - bot.add_cog(Logs(bot)) +async def setup(bot): + await bot.add_cog(Logs(bot)) diff --git a/cogs/player.py b/cogs/player.py index ae328a5..cf896fe 100755 --- a/cogs/player.py +++ b/cogs/player.py @@ -336,20 +336,20 @@ class Player(commands.Cog): search: str [Required] The song to search and retrieve using YTDL. This could be a simple search, an ID or URL. """ - await ctx.trigger_typing() - vc = ctx.voice_client + async with ctx.typing(): + vc = ctx.voice_client - if not vc: - await ctx.invoke(self.connect_) + if not vc: + await ctx.invoke(self.connect_) - player = self.get_player(ctx) + player = self.get_player(ctx) - # If download is False, source will be a dict which will be used later to regather the stream. - # If download is True, source will be a discord.FFmpegPCMAudio with a VolumeTransformer. - source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop) + # If download is False, source will be a dict which will be used later to regather the stream. + # If download is True, source will be a discord.FFmpegPCMAudio with a VolumeTransformer. + source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop) - await player.queue.put(source) + await player.queue.put(source) @commands.command(name="pause") async def pause_(self, ctx): @@ -497,5 +497,5 @@ class Player(commands.Cog): p.unlink() -def setup(bot): - bot.add_cog(Player(bot)) +async def setup(bot): + await bot.add_cog(Player(bot)) diff --git a/cogs/src.py b/cogs/src.py index ff9ad8a..47607ef 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -477,5 +477,5 @@ class Src(commands.Cog): continue -def setup(bot): - bot.add_cog(Src(bot)) +async def setup(bot): + await bot.add_cog(Src(bot)) diff --git a/cogs/trans.py b/cogs/trans.py index a18206f..eb4246a 100755 --- a/cogs/trans.py +++ b/cogs/trans.py @@ -74,5 +74,5 @@ class Trans(commands.Cog): await ctx.send(embed=embed) -def setup(bot): - bot.add_cog(Trans(bot)) +async def setup(bot): + await bot.add_cog(Trans(bot)) diff --git a/cogs/twitter.py b/cogs/twitter.py index d668d47..8202b00 100755 --- a/cogs/twitter.py +++ b/cogs/twitter.py @@ -56,5 +56,5 @@ class Twitter(commands.Cog): stream.filter(follow=["1287799985040437254"], is_async=True) -def setup(bot): - bot.add_cog(Twitter(bot)) +async def setup(bot): + await bot.add_cog(Twitter(bot)) diff --git a/cogs/utils.py b/cogs/utils.py index 51ca1e0..a9dc2fe 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -6,8 +6,8 @@ import subprocess import unicodedata from collections import namedtuple from datetime import timedelta -from random import choice, randint from math import floor +from random import choice, randint import discord from discord.ext import commands @@ -133,19 +133,6 @@ class Utils(commands.Cog): f"{discord.utils.escape_mentions(ctx.message.author.display_name)} -> your seed is a {total_eyes} eye" ) - @findseed.error - async def findseed_handler(self, ctx, error): - if isinstance(error, commands.CommandOnCooldown): - if ctx.message.channel.id != int( - self.bot.config[str(ctx.message.guild.id)]["bot_channel"] - ): - ctx.command.reset_cooldown(ctx) - await ctx.message.delete() - return - else: - await ctx.send(error) - # await ctx.send(f"{discord.utils.escape_mentions(ctx.message.author.display_name)}, you have to wait {round(error.retry_after, 7)} seconds before using this again.") - @commands.command() async def findsleep(self, ctx): """Test your sleep""" @@ -410,6 +397,7 @@ class Utils(commands.Cog): if message.reference is not None and len(message.content) == 0: reply = await message.channel.fetch_message(message.reference.message_id) if reply.is_system(): + def check(m): return ( m.author == message.author @@ -713,10 +701,8 @@ class Utils(commands.Cog): @commands.command() async def someone(self, ctx): """Discord's mistake""" - if ctx.channel.id != int( - self.bot.config[str(ctx.message.guild.id)]["fair_channel"] - ): - await ctx.send(choice(ctx.guild.members).mention) + + await ctx.send(choice(ctx.guild.members).mention) @commands.command() async def roll(self, ctx, pool): @@ -780,6 +766,5 @@ class Utils(commands.Cog): ) -def setup(bot): - bot.add_cog(Utils(bot)) - +async def setup(bot): + await bot.add_cog(Utils(bot)) diff --git a/cogs/webserver.py b/cogs/webserver.py index 223dff5..5e25812 100755 --- a/cogs/webserver.py +++ b/cogs/webserver.py @@ -53,5 +53,5 @@ class Webserver(commands.Cog): await self.bot.wait_until_ready() -def setup(bot): - bot.add_cog(Webserver(bot)) +async def setup(bot): + await bot.add_cog(Webserver(bot)) |