Kuro-Cogs

Discord Name: K u r o#2740

GitHub Repository (Must be V3):

Description:
A collection of cogs that was made by Kuro for Red-DiscordBot v3. This repo has a total of 13 cogs where 3 cogs (BotPing, Osu, and Sudo) were rewritten and 3 cogs (DankTax, Hack, and ReactLog) were inspired by another bot.

1 Like

Just a little update:

  • Added 1 more cog (Calendar), so 14 cogs in total now
  • Most of the cogs are dpy2 ready now (on dpy2 branch)

With the release of 3.5, we are returning to reviewing Cog Creator applications.

Since 3.5 will break every cog that was not specifically coded with it in mind, you need to ensure your repo is updated to be compatible with 3.5 prior to a review being possible. The relevant documentation you will need to update your repo is the following:
-discord.py 2.0 migration: https://discordpy.readthedocs.io/en/v2.2.3/migrating.html
-Red 3.5 breakages: https://docs.discord.red/en/stable/incompatible_changes/3.5.html#incompatible-changes-3-5

Once your repo is updated to support 3.5 on the default branch, please make a comment in this thread to confirm you are once again ready for review. We will only be reviewing repos which comment to confirm 3.5 support, but we will prioritize repos that have been in the queue for a longer period of time first.

If you wish to revoke your application, please comment accordingly so we can clean up the thread. If you need time to make changes, but are actively working on making updates, please also comment accordingly. Applications which do not see any activity within 1 month from today will be closed.

Sorry for the long wait, Flameā€¦

My repo is finally updated to support 3.5 on the main branch (which is the default branch)
Itā€™s ready for review now :smiley:

Hi Kuro, I will be starting to take a look at your repo soon. I will post here when I have the review ready for you.

1 Like

Hi Kuro, thanks for your patience while I worked on reviewing your repo.

Commit hash 7c88c472a2b16f632f03029882cd589b80753854 from 6/20

Your repo install message includes ā€œUse [p]cog list kuro-cogs to see available cogs.ā€ but someone may have installed it under a different repo name. Most folks using the index will copy-paste the repo install instruction so this may not need to be changed, but I thought Iā€™d mention the possibility.

Your cog install messages say things like Thanks for installing Cogname! Use .help Cogname to see all the available commands. You may want to say something like ā€œUse .help Cogname to see all the available commands after loading the cog.ā€ to prompt users to load the cog first.

Ignored: docs, as itā€™s not a cog package

Very nice docs site. Helps users to figure out cogs that have documentation like this, even if it is reposting of docstrings.

The few things I feel are required are prefixed by Fix: in the list below.

AvatarImgen
Fix: None of the commands work because the APIs are down, or the site is now gone - some-random-api.ml doesnā€™t exist any more. You can fix this cog by finding a new API or two, or removing it, or setting it to disabled in the info.json.

Calendar
No requested changes.

You may want to use discord.datetime.utcnow() instead of datetime.utcnow() - https://discordpy.readthedocs.io/en/v2.2.3/migrating.html#datetime-objects-are-now-utc-aware.

Chairs
No requested changes.

Cogcount
No requested changes.

DankUtils
No requested changes.

FakeMod
No requested changes.

You may want to provide a note at the bottom of the current settings display on how to change emojis, like saying something like ā€œUse [p]help fakemodlogset emoji for settingsā€ or similar.

Fumo

Fix: [p]fumoroid, marisafie, and marisahat error out.

ERROR [red] Exception in command 'fumoroid'
Traceback (most recent call last) 
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:229 in wrapped 
ā± 229 ret = await coro(*args, **kwargs) 
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/fumo/fumo.py:111 in fumoroid 
ā± 111 avatar = await get_avatar(user) 
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/fumo/utils.py:44 in get_avatar 
ā± 44 await user.avatar_url_as(static_format="png").save(avatar, seek_begin=True) 

AttributeError: 'Member' object has no attribute 'avatar_url_as'

Osu

Fix: Your dependency git+https://github.com/NiceAesth/aiosu does not install on Python 3.8.x, which is still supported by Red. Add a key to this cogā€™s info.json to declare that Python 3.9 is the minimum Python version to use with this cog.

The osu link command does not explain how to link your account.

I canā€™t fully test this cog as I donā€™t use the dashboard so you may have other user-facing issues present.

You should probably mention somewhere that this cog queries an external API and sends over their player username to it (Martineā€™s API for the profile image generation). Maybe in the cog install message so that itā€™s the bot ownerā€™s responsibility to communicate that to their users, but Iā€™ll leave that up to you to decide.

I used [p]help Osu and got this traceback one time, but not when I used it a different time. The help displayed showed the unawaited coroutine, see https://cdn.discordapp.com/attachments/321143541638234112/1122317009397481573/osuhelp.png

WARNING  [py.warnings] /Users/aikaterna/red39/lib/python3.9/site-packages/redbot/core/commands/help.py:566: RuntimeWarning: coroutine 'OsuMixin.format_help_for_context' was never awaited
  description = obj.format_help_for_context(ctx)

Reactlog

For the the handle_ghost_channel function, while I like the idea of being able to clean settings out of Config when there is a channel missing, I have had pushback against this from users when I implemented it in a cog. A channel can become unavailable temporarily if someone removes the bot from the channel or other reasons, but if they put it back later, all of their settings are gone.

Kind of amusing to find code that I wrote in a repo Iā€™m reviewing, thanks for the code attribution to other folksā€™ work in this cog.

Sudo

This is only my opinion and it doesnā€™t come from an official standpoint where you would have to modify this cog to keep it on your repo. I donā€™t expect you to change things based on my opinion, but I wanted to talk about it a little.

Personally, I feel like you should not be modifying attributes that are on the bot class during runtime with a 3rd party cog, like the owner list. I was inclined to ask you to remove this cog or set it as hidden for my approval, but in talks with other folks they seem to be more permissive on this point. In my opinion, contributing or testing Jackā€™s draft PR on Red itself for this feature instead of a 3rd party cog would be more attractive, but that is not for me to enforce or say that you should do that instead of providing choices via 3rd party cogs.

Translate

Used [p]translate 恊ćÆ悈恆 --to English --translator libre. Seemed to be a temporary issue where there was nothing in the response from the site, as it worked later.

ERROR [red] Exception in command 'translate'
Traceback (most recent call last)
/Users/aikaterna/red39/lib/python3.9/site-packages/discord/ext/commands/core.py:229 in wrapped
ā± 229 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/translate/translate.py:99 in translate
ā± 99 result = await self._translate(
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/translate/translate.py:179 in _translate
ā± 179 result = await self.bot.loop.run_in_executor(
/opt/homebrew/Cellar/python@3.9/3.9.17/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py:58 in run
ā± 58 result = self.fn(*self.args, **self.kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/base.py:110 in translate
ā± 110 source_language, translation = self._translate(text, dest_code, source_code)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/libre.py:22 in _translate
ā± 22 source_language = self._language(text)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/libre.py:33 in _language
ā± 33 return response.json()[0]["language"]
KeyError: 0

Used flag_cu as a reaction on a message with translateset react enabled, where no service was able to return a valid result.

ERROR [red.kuro-cogs.translate] Error while translating message (ID: 0000000000000000000) with reaction.
Traceback (most recent call last)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/mymemory.py:32 in _translate
ā± 32 result = request.json()["matches"][0]
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translate.py:135 in translate
ā± 135 return _translate(translator=service, index=index)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translate.py:107 in _translate
ā± 107 result = translator.translate(
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/base.py:110 in translate
ā± 110 source_language, translation = self._translate(text, dest_code, source_code)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translators/mymemory.py:34 in _translate
ā± 34 raise MyMemoryException("NO_MATCH")

MyMemoryException: NO_MATCH | There is no match to the translation

The above exception was the direct cause of the following exception:

Traceback (most recent call last)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/translate/translate.py:162 in on_reaction_add
ā± 162 result = await self._translate(message.content, Translator(), str(language))
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/translate/translate.py:179 in _translate
ā± 179 result = await self.bot.loop.run_in_executor(
/opt/homebrew/Cellar/python@3.9/3.9.17/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py:58 in run
ā± 58 result = self.fn(*self.args, **self.kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/translatepy/translate.py:140 in translate
ā± 140 raise NoResult("No service has returned a valid result") from exception

NoResult: No service has returned a valid result

Hello Aika, sorry for the late reply :stuck_out_tongue:
All changes of your review is done and available at fd4eaa3b5fe3dc22fa0054a6b0e754441e23e5a8

Iā€™ve considered to do these:

  • Removed AvatarImgen as I donā€™t really maintain it anymore
  • Changed datetime.datetime.utcnow() to discord.utils.utcnow() in Calendar cog
  • Fixed removed method from Fumo cog that I somehow forgot to migrate
  • Added ā€œHow to Linkā€ button that shows steps on how to link osu! account
  • Changed the code of handle_ghost_channel function in ReactLog cog so it doesnā€™t remove the saved config when logs canā€™t be send to a channel
  • Make Sudo cog hidden
  • Removed translate cog because the lib is bad and there are better alternatives (such as Trustyā€™s)

Once again, Thank You Aika :slight_smile:

Sooā€¦ I brought back Translate with some fixes. So just ignore the last point, been a bit stressed :stuck_out_tongue:

Hi Kuro, could you please address the issue with the Fumo cog that I mentioned? Seems to be still occurring. The issues with Translate are still present too, but I am only requiring Fumo changes at the moment because that change is dpy2/Red 3.5 related. Thanks for working on a lot of the optional suggestions I had as well.

Just realized I missed that, sorry. The issue for the Fumo cog is fixed now.

Looks like youā€™ll need to specify a pillow version less than 10.0 for that cog in the info.json as the Image.ANTIALIAS function was removed but everything Iā€™ve asked for is done, so you should see some pings soon as youā€™re assigned the roles and such for Cog Creator. Thanks for your patience :slight_smile: