Skip to content

Conversation

@Ibrahim2750mi
Copy link
Contributor

#2394

  • /tag list lists all the accessible tags
  • /tag get <tag_name> empty <tag_name> returns the same output as /tag list
  • removed the search sub-group

Screenshots:

2023-02-14_18-47_1
2023-02-14_18-47_2
2023-02-14_18-47

Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently getting an error when running this if there are too many matches, we should probably trim the results in these cases:

bot-bot-1          | 2023-02-19 15:45:18 | asyncio | ERROR | Task exception was never retrieved
bot-bot-1          | future: <Task finished name='CommandTree-invoker' coro=<CommandTree._from_interaction.<locals>.wrapper() done, defined at /opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py:1089> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn data.choices: Must be 25 or fewer in length.')>
bot-bot-1          | Traceback (most recent call last):
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1091, in wrapper
bot-bot-1          |     await self._call(interaction)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1238, in _call
bot-bot-1          |     await command._invoke_autocomplete(interaction, focused, namespace)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/commands.py", line 931, in _invoke_autocomplete
bot-bot-1          |     await interaction.response.autocomplete(choices)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/interactions.py", line 966, in autocomplete
bot-bot-1          |     await adapter.create_interaction_response(
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/webhook/async_.py", line 220, in request
bot-bot-1          |     raise HTTPException(response, data)
bot-bot-1          | discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
bot-bot-1          | In data.choices: Must be 25 or fewer in length.

I think we should try to avoid any cases of "The application did not respond" errors on the client. Another case where this can happen is where no match can be found e.g. /tag get fionferonfero

@Ibrahim2750mi
Copy link
Contributor Author

I'm currently getting an error when running this if there are too many matches, we should probably trim the results in these cases:

bot-bot-1          | 2023-02-19 15:45:18 | asyncio | ERROR | Task exception was never retrieved
bot-bot-1          | future: <Task finished name='CommandTree-invoker' coro=<CommandTree._from_interaction.<locals>.wrapper() done, defined at /opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py:1089> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn data.choices: Must be 25 or fewer in length.')>
bot-bot-1          | Traceback (most recent call last):
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1091, in wrapper
bot-bot-1          |     await self._call(interaction)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1238, in _call
bot-bot-1          |     await command._invoke_autocomplete(interaction, focused, namespace)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/app_commands/commands.py", line 931, in _invoke_autocomplete
bot-bot-1          |     await interaction.response.autocomplete(choices)
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/interactions.py", line 966, in autocomplete
bot-bot-1          |     await adapter.create_interaction_response(
bot-bot-1          |   File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.10/lib/python3.10/site-packages/discord/webhook/async_.py", line 220, in request
bot-bot-1          |     raise HTTPException(response, data)
bot-bot-1          | discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
bot-bot-1          | In data.choices: Must be 25 or fewer in length.

Fixed.

+ Remove commented code
+ Remove unecessarily syncting the bot
+ Handle direct tag commads
+ 3.10 type hinting in concerned functions
+ Add `MockInteractionMessage`
+ Fix tests for `try_get_tag`
@Ibrahim2750mi Ibrahim2750mi requested review from shtlrs and wookie184 and removed request for Den4200, jb3, shtlrs and wookie184 February 22, 2023 22:42
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks!

I wonder whether it would be better to just have a /tag <name> command, since currently /tag get with no arguments is the same as /tag list, so i'm not sure there's any point in having two commands. One would be shorter to type and simplify the code a little.

@Ibrahim2750mi
Copy link
Contributor Author

Ibrahim2750mi commented Feb 25, 2023

I wonder whether it would be better to just have a /tag <name> command, since currently /tag get with no arguments is the same as /tag list, so i'm not sure there's any point in having two commands. One would be shorter to type and simplify the code a little.

I had a conversation about this on discord with @ChrisLovering, he suggested making the commands like that.

@wookie184 wookie184 linked an issue Feb 25, 2023 that may be closed by this pull request
+ used both `discord.User` and `discord.Member` in typehinting as `InteractionResponse.user` returns `discord.User` object
+ removed `ErrorHandler()._can_run`
+ edited `try_get_tag` to use `bot.can_run`
+ removed `/tag list`
+ change `/tag get <name>` to `/tag <name>`
+ remove redundant `GUILD_ID` in `tags.py`
+ using `discord.abc.Messageable` because `ctx.channel` returns that instead of `Channel` Object
@Ibrahim2750mi Ibrahim2750mi requested review from shtlrs and wookie184 and removed request for shtlrs and wookie184 February 26, 2023 12:16
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

Copy link
Member

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nitpicks, other than that, it looks good !

+ removed using of discord.User
+ update docstring for `get_command_ctx`
+ renamed user variables to member
@Ibrahim2750mi Ibrahim2750mi requested a review from shtlrs February 27, 2023 11:43
Copy link
Member

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@wookie184 wookie184 enabled auto-merge February 27, 2023 19:27
@wookie184 wookie184 merged commit 909fb61 into python-discord:main Feb 27, 2023
@Ibrahim2750mi Ibrahim2750mi deleted the migration/tag branch February 27, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrating !tag to slash commands

4 participants