Discord Name: Obi-Wan3#0003
GitHub Repository (Must be V3): https://github.com/Obi-Wan3/OB13-Cogs
Description: Assorted utility cogs that I have created over the past few months.
Discord Name: Obi-Wan3#0003
GitHub Repository (Must be V3): https://github.com/Obi-Wan3/OB13-Cogs
Description: Assorted utility cogs that I have created over the past few months.
Hi Obi-Wan3, thank you for your patience while I review your repo.
Commit hash at time of review - 578364513502be320f9dc19b690a003521c74f2d
message.channel.id != counting_channel
If counting_channel
is None then message.channel.id
will never be equal. (Optional)@commands.mod_or_permissions(manage_messages=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)[p]createvoice
Needs to have additional checks for manage_channels
. The @commands.bot_has_permissions(manage_channels=True)
only checks for channel specific permissions. You need to also check inside the function for ctx.guild.me.guild_permissions.manage_channels
.@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)await user.send(message)
https://discordpy.readthedocs.io/en/latest/api.html#discord.User.create_dm
//
with \/\/
otherwise you may get warnings from future python versions about issues compiling this regex. (Optional)[p]emojitools tozip
should have checks that the file size is under the limit of the server it’s sending to. While it’s unlikely to encounter a set of emojis that are zipped and larger thant the server’s upload limit, it is possible when you consider there was a brief period of about a week where there was no size limit on discord emojis and people uploaded very large emojis in that time, some already compressed as much as possible.before_loop
function. E.g.@tasks.loop(minutes=3)
async def _github_rss(self):
# Your code
...
@_github_rss.before_loop
async def _before_github_rss(self):
await self.bot.wait_until_red_ready()
This is listed under the discord.py tasks API documentation under “Waiting until the bot is ready before the loop starts” https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#recipes
[p]github setchannel
and [p]github channel
commands should also check that the designated channel has permission to send and embed links before saving. Otherwise someone could setup a channel with incorrect permissions and not know why it’s not working.min_bot_version
is too low, since you’re using get_or_fetch_user
which was introduced in Red 3.4.1.@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)[p]privaterooms add
command you should be checking that you actually have manage channels permission either on a guild level or within the designated category channels so that users setting this up are not confused why it doesn’t work for them after setting it up.[p]privaterooms logchannel
command you should be checking that the provided channel if present has correct permissions for the bot to send to so that once it’s setup users aren’t confused why the logs aren’t working.@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)[p]publicrooms add
command you should be checking that you actually have manage channels permission either on a guild level or within the designated category channels so that users setting this up are not confused why it doesn’t work for them after setting it up.[p]publicrooms logchannel
command you should be checking that the provided channel if present has correct permissions for the bot to send to so that once it’s setup users aren’t confused why the logs aren’t working.await user.send(message)
https://discordpy.readthedocs.io/en/latest/api.html#discord.User.create_dm
discord.errors.Forbidden
in fact you can create a DM with anyone even if you can’t DM them. You also don’t return after sending the message that the user does not have DMs enabled meaning further commands will all fail with an ugly message.if cond is True
or if cond is False
not if cond == True
. (Optional)AttributeError
trying to get role.name
.MessagePredicate
is almost right here although it might be simpler to do this:pred = MessagePredicate.lower_contained_in(['cancel', 'start'], channel=ctx.author.dm_channel, user=ctx.author)
try:
await self.bot.wait_for("message", check=pred, timeout=60)
except asyncio.TimeoutError:
return await ctx.author.send("The operation has timed out. Please try again.")
if pred.result == 0: # pred.result returns the index number of the item in the collection
return await ctx.author.send("Quiz cancelled.")
else:
# continue with the quizz
pass
You can work this in with the entire quiz although I will make this an optional change. (Optional)
@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)[p]quizroleset newquiz
and [p]quizroleset edit
you need to check that the bot actually has permissions to manage roles.[p]referset logchannel
you should be checking that the bot has permission to send messages in this channel.@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)AsyncIter
here because iterating through a server like Red with over 10000 members can take a lot of time and potentially block the bot from responding in other servers until this function is done. (Optional)message.channel.id == ctx.channel.id
(Optional)allowed_mentions=discord.AllowedMentions(roles=False)
to this so you’re not mass pinging people who are using these commands. This will also increase min_bot_version
to 3.4.1. (Optional)@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)before_loop
function. E.g.@tasks.loop(minutes=3)
async def _fetch_statuses(self):
# Your code
...
@_fetch_statuses.before_loop
async def _before_fetch_statuses(self):
await self.bot.wait_until_red_ready()
This is listed under the discord.py tasks API documentation under “Waiting until the bot is ready before the loop starts” https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#recipes
online
in self._fill_template
for the offline_fille
variable. I am not sure if this was intentional or not but now offline
is an unused variable. (Optional)@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)@commands.admin_or_permissions(administrator=True)
will allow these commands to function even if the server owner has not setup mod and admin roles in the server prior to starting. (Optional)allowed_mentions=discord.AllowedMentions(roles=False)
here or using role.name
so that you don’t have accidental mass pinging. (Optional)from redbot.core.utils.chat_formatting import humanize_timedelta
here to display a nice user friendly time until. (Optional)NoneType object has no attribute 'mention'
if the roles or channels have been deleted.Some things I wanted to comment on in general. You tend to use ctx.tick()
a LOT which is fine although it often gives little feedback to users on what actually changed. It’s nicer to know what the setting was changed to without having to dig for another command to see what the settings are now. This is also somewhat problematic where Red doesn’t guarantee the add_reactions permission for bots and we barely guarantee send messages permission but in this case ctx.tick()
will fail silently if no permission to add reactions is present leaving users unsure if the command actually functioned if their permission structure prevents the bot from adding reactions. These things make it difficult for you to try and diagnose issues with why your cog may not be working for users. I would also recommend looking at setting up proper logging for things. You have channels setup for a lot of cogs to log error messages, etc. but there’s no checks that the logging channel actually exists or that the bot even has permission to send messages in it which in some cases lead to cascading errors that you won’t exactly know how to fix.
I know it seems like there’s a lot of issues here but they should be relatively straight forward and many of them are the same issue between cogs so once you solve the problem in one it’s simply following the same idea in the next.
Hi Trusty, thank you so much for your review! I have made the changes on my dev branch (all of the required changes and the majority of the optional changes); please let me know if anything is missing or seems incorrect (I will push to main once it is confirmed that everything seems valid). For the ctx.tick()
issue, I have decided to stick with using that instead of adding individual confirmation messages for quite a few of the commands. I will definitely look further into logger
in the future, but for now I have added checks for send message permissions to the in-Discord log channels for my cogs. For StatusRole
, I decided to go with the core Filter
approach and removed the user-set regex feature.
Thanks for making these changes. Once they’re on your main branch I am happy to mark this as approved!