pycord
pycord copied to clipboard
`discord.Emoji` and `discord.PartialEmoji` didn't work in slash option.
Summary
The slash command didn't work when I add slash option which contains Union[discord.Emoji, discord.PartialEmoji]
type
Reproduction Steps
I tested code that has attribute type Union[discord.Emoji, discord.PartialEmoji]
and this command didn't synced with guilds.
Minimal Reproducible Code
@discord.commands.slash_command(name="test")
async def emoji(self, ctx: discord.ApplicationContext, emoji : Union[discord.Emoji, discord.PartialEmoji]):
await ctx.respond(emoji.name)
Expected Results
I want the slash option support for discord.Emoji
and discord.PartialEmoji
Actual Results
The command didn't synced with guilds.
Intents
intents = discord.Intents.all()
System Information
- Python v3.10.2-final
- py-cord v2.0.1-final
- aiohttp v3.8.1
- system info: Windows 10 10.0.22000
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
No response
discord.Emoji
is not a valid option type.
Can you try using only discord.Emoji
, this should use the converter
Can you try using only
discord.Emoji
, this should use the converter
Code that I tested
@discord.commands.slash_command(name="test")
async def emoji(self, ctx: discord.ApplicationContext, emoji : discord.Emoji):
await ctx.respond(emoji.name)
I got this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: EmojiConverter.convert() missing 1 required positional argument: 'argument'
This should be fixed in the latest release
This should be fixed in the latest release
Well, I tested that code in py-cord version 2.1.1 with 1️⃣ emoji but it raised this error
discord.ext.commands.errors.EmojiNotFound: Emoji "1️⃣" not found.
This should be fixed in the latest release
Well, I tested that code in py-cord version 2.1.1 with 1️⃣ emoji but it raised this error
discord.ext.commands.errors.EmojiNotFound: Emoji "1️⃣" not found.
Try with a custom emoji, 1️⃣ is technically only a unicode character and not considered an emoji by the parser.
Hi, I have related but not the same problem with Emojis.
I made dropdown menu that user can customize with commands. I didn't found any proper way to pass unicode emoji through command. But why would I need a unicode emoji, you might ask? Because discord.SelectOption
doesn't like standard discord emoji format (e.g. :bulb
), it works with unicode just fine. It also has no problem with cusotm emojis for some reason.
Error message that i get:
Traceback (most recent call last):
File "/home/rafaln/.local/lib/python3.10/site-packages/discord/bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/rafaln/.local/lib/python3.10/site-packages/discord/commands/core.py", line 375, in invoke
await injected(ctx)
File "/home/rafaln/.local/lib/python3.10/site-packages/discord/commands/core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0.options.0.emoji.name: Invalid emoji
I used this example and modified it a little bit:
options = [
discord.SelectOption(
label="Red", description="Your favourite colour is red", emoji=":smile:"
),
discord.SelectOption(
label="Green", description="Your favourite colour is green", emoji="⚗"
),
discord.SelectOption(
label="Blue", description="Your favourite colour is blue", emoji="<:troll:910540961958989934>"
),