Kozejin-cogs

Discord Name: KoZ#1337

GitHub Repository (Must be V3): [redacted]

Description:
Creating cogs that retrieve game related information from different APIs. The cogs have been tested and function as intended. The CloneTracker cog tracks information related to diablo clones in the game Diablo 2. The pokedex allows users to look up pokemon and game items, I will be expanding on this.

Hi Koz, I am going to start reviewing your repo when I have a bit to do so. I’ll let you know what I find here in another post at that time.

Hi Koz, thanks for your patience. A lot of these comments are suggested and not required. Required comments have been noted next to the comment - please let me know if you have any questions.

CloneTracker

(Required) Need to add aiocache install to info.json
You should be able to use one check for data - “if data is None” and “if not data” should be functionally equivalent

DeckardCain

You may want to use Red’s shared API key storage, so that the Open API key can be shared between cogs. Shared API Keys — Red - Discord Bot 3.5.5 documentation

It seems a bit strange that the API key is saved per-guild but the setcainapi command is only usable by the bot owner.

It’s possible that the bot won’t have the permissions for your ctx.message.delete() call in the setcainapi command, causing a traceback. Maybe you could prompt the user to use the command in DMs instead, so you don’t have to delete the API key message.

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/deckardcain/deckardcain.py:27 in setcainapikey
❱ 27 await ctx.message.delete()
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/message.py:859 in delete
❱859 await self._state.http.delete_message(self.channel.id, self.id)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/http.py:739 in request
❱739 raise Forbidden(response, data)

Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

For the askcain command, there is no asyncio.to_thread() on Python 3.8.x, which is still supported by Red.

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/deckardcain/deckardcain.py:51 in askcain
❱ 51 response = await self.generate_response(question, api_key)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/deckardcain/deckardcain.py:72 in generate_response
❱ 72 response = await asyncio.to_thread(openai.Completion.create, model="text-curie-001", prompt=prompt, max_tokens=476, temperature=0.5)
AttributeError: module 'asyncio' has no attribute 'to_thread'

You may want to add a friendly message for if the user has not enabled billing/added a payment method to their OpenAI key. I modified your code to bypass any issues and pass the query to the service to check it, and received this trace - so the line numbers and code shown will not match up exactly to your work, but this lets you know what sort of exception to catch if you wish to do so.

You may also want to let users know that after creating a new key and applying a billing method, it will take a few minutes at least for it to become available to use through the cog.

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱ 235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/deckardcain/deckardcain.py:51 in askcain
❱ 51 response = await self.generate_response(question, api_key)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/deckardcain/deckardcain.py:72 in generate_response
❱ 72 response = openai.Completion.create(model="text-curie-001", prompt=prompt, max_tokens=476, temperature=0.5)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/openai/api_resources/completion.py:25 in create
❱ 25 return super().create(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/openai/api_resources/abstract/engine_api_resource.py:155 in create
❱ 155 response, _, api_key = requestor.request(
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/openai/api_requestor.py:299 in request
❱ 299 resp, got_stream = self._interpret_response(result, stream)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/openai/api_requestor.py:710 in _interpret_response
❱ 710 self._interpret_response_line(
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/Downloader/lib/openai/api_requestor.py:775 in _interpret_response_line
❱ 775 raise self.handle_error_response(

RateLimitError: You exceeded your current quota, please check your plan and billing details.

The model you chose, text-curie-001, is deprecated.
“warning”: “This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more OpenAI Platform

Pokedex
(Required) Need to add aiocache install to info.json

Speak
[p]speak addbutton has some curious behaviour when using an invalid url.

  1. use help on a command, like just running [p]speak
  2. use [p]speak addbutton on the returned embed
  3. enter a name for the button, and enter an invalid url for the button
  4. Invalid URL message appears
  5. Message appears saying the button was added
  6. the original embed is edited to only show the Syntax + Alias code block and none of the content
  7. there are no buttons added to the embed

[p]speak embed includes a message deletion that the bot may not have permissions for

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/speaker/speaker.py:24 in speak_embed 
❱24 await ctx.message.delete()
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/message.py:859 in delete 
❱859 await self._state.http.delete_message(self.channel.id, self.id)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/http.py:739 in request 
❱739 raise Forbidden(response, data)
Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

[p]speak say has no checks if the bot can speak in the target channel

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/speaker/speaker.py:18 in speak_say 
❱18 await ctx.message.delete()
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/message.py:859 in delete 
❱859 await self._state.http.delete_message(self.channel.id, self.id)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/http.py:739 in request 
❱739 raise Forbidden(response, data)
Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

[p]speak say also includes a message deletion that the bot may not have permissions for

Traceback (most recent call last)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/ext/commands/core.py:235 in wrapped
❱235 ret = await coro(*args, **kwargs)
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/speaker/speaker.py:18 in speak_say 
❱18 await ctx.message.delete()
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/message.py:859 in delete 
❱859 await self._state.http.delete_message(self.channel.id, self.id)
/Users/aikaterna/red38/lib/python3.8/site-packages/discord/http.py:739 in request 
❱739 raise Forbidden(response, data)

Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

Using [p]speak edit on a message with an embed changes one line in the embed, but doesn’t edit the rest of the embed

Steam

You should remove the requests import, it’s unused.

(Required) Doesn’t seem to be loadable on Python 3.8.x, which is still supported by Red. You will need to update the info.json for the minimum python version where this cog can be installed or find a way to resolve this traceback.

Traceback (most recent call last) 
/Users/aikaterna/red38/lib/python3.8/site-packages/redbot/core/core_commands.py:188 in _load
❱188 await bot.load_extension(spec) 
/Users/aikaterna/red38/lib/python3.8/site-packages/redbot/core/bot.py:1680 in load_extension
❱ 1680 lib = spec.loader.load_module()
in _check_name_wrapper:522
in load_module:1022 
in load_module:847
in _load_module_shim:265
in _load:702
in _load_unlocked:671 
in exec_module:843
in _call_with_frames_removed:219
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/steam/__init__.py:1 in <module>
❱ 1 from .steam import SteamAPI 
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/steam/steam.py:3 in <module> 
❱ 3 import requests 
/Users/aikaterna/red38/lib/python3.8/site-packages/requests/__init__.py:45 in <module>
❱45 from .exceptions import RequestsDependencyWarning 
/Users/aikaterna/red38/lib/python3.8/site-packages/requests/exceptions.py:9 in <module> 
❱ 9 from .compat import JSONDecodeError as CompatJSONDecodeError
/Users/aikaterna/red38/lib/python3.8/site-packages/requests/compat.py:47 in <module>
❱ 47 from http import cookiejar as cookielib

ImportError: cannot import name 'cookiejar' from 'http' (/opt/homebrew/Cellar/python@3.8/3.8.17/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/__init__.py)

(Required) The Steam library you are using needs to be added to the info.json so the cog can install it on cog install.

Traceback (most recent call last)
/Users/aikaterna/red39/lib/python3.9/site-packages/redbot/core/core_commands.py:188 in _load
❱188 await bot.load_extension(spec) 
/Users/aikaterna/red39/lib/python3.9/site-packages/redbot/core/bot.py:1680 in load_extension
❱ 1680 lib = spec.loader.load_module()
in _check_name_wrapper:529
in load_module:1029 
in load_module:854
in _load_module_shim:274
in _load:711
in _load_unlocked:680 
in exec_module:850
in _call_with_frames_removed:228
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/steam/__init__.py:1 in <module>
❱ 1 from .steam import SteamAPI 
/Users/aikaterna/Library/Application Support/Red-DiscordBot/data/catdev/cogs/CogManager/cogs/steam/steam.py:5 in <module> 
❱ 5 from steam.steamid import SteamID 

ModuleNotFoundError: No module named 'steam.steamid'

I wasn’t able to get this cog loaded on my test bot, nor guess what Steam library you are using (I used [p]pipinstall steam to try, but received the same traceback as above).

Timestamps

You may want to remind people to use [p]slash sync after installing this cog, or they may be confused why the slash command isn’t showing up.
You may want to provide people with examples of how you are expecting the date to be formatted.

Going to be applying all the fixes on a separate branch. I’ll look into why the steam library isn’t installing correctly, it might be a later python version.