You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my opinion, it presents the following problems:
It works with IDs only, which requires the used to have the developer mode enabled
You can't use message links, which is now the user-friendly way of referencing a message
The new_message thing is confusing. Copying from a message to another may be a good idea, but it's complicated to use. You either have to reference another message using the same methods described above, or type the content which must be preceded by a 0.
How it could be better
discord.Message
A message converter was added to discord.py (hehe I made it :D) and supports the following formats:
Message link
<channel ID>-<message ID> (obtained by holding shift when copying message ID, the old way for discord to reference a message to support)
Message ID only, provided the message is in the context channel
That alone makes everything a lot easier for the users, only one argument for referencing the message, without needing the developer mode turned on.
typing.Union
Another great feature that you're already using, but at this point you get what I'm about to say. Make the last argument a union between discord.Message and str. If it fails to parse a message link, last argument will be a simple string.
typing.Optional
Another² great feature, if you want an optional argument preceded by a required argument, you should use this.
The way it works is simple: parse the next word (or quoted sentence), if it fits the required type for the optional parameter, use it, else pass it to the next argument.
With that, you can ditch the 0 thing easily.
In the end, you have two ways of building the command:
Using typing.Union [p]editmessage <og_message> <existing_message|content>
Using typing.Optional [p]editmessage <og_message> [existing_message] [content]
The latter could let the user combine an existing message with his own content.
The text was updated successfully, but these errors were encountered:
Hey, some users are asking me an edit message feature for my Say cog and I redirect them to your cog. However, I noticed it's not really easy to use.
I think this could be made way easier to use by using the
discord.Message
andtyping.Union
type hinters in your command.Why
The current design of the command is as follows:
[p]editmessage <og_channel_id> <og_message_id> <new_message_id|0> <new_message_content|content>
In my opinion, it presents the following problems:
new_message
thing is confusing. Copying from a message to another may be a good idea, but it's complicated to use. You either have to reference another message using the same methods described above, or type the content which must be preceded by a0
.How it could be better
discord.Message
A message converter was added to discord.py (hehe I made it :D) and supports the following formats:
<channel ID>-<message ID>
(obtained by holding shift when copying message ID, the old way for discord to reference a message to support)That alone makes everything a lot easier for the users, only one argument for referencing the message, without needing the developer mode turned on.
typing.Union
Another great feature that you're already using, but at this point you get what I'm about to say. Make the last argument a union between
discord.Message
andstr
. If it fails to parse a message link, last argument will be a simple string.typing.Optional
Another² great feature, if you want an optional argument preceded by a required argument, you should use this.
The way it works is simple: parse the next word (or quoted sentence), if it fits the required type for the optional parameter, use it, else pass it to the next argument.
With that, you can ditch the
0
thing easily.In the end, you have two ways of building the command:
Using
typing.Union
[p]editmessage <og_message> <existing_message|content>
Using
typing.Optional
[p]editmessage <og_message> [existing_message] [content]
The latter could let the user combine an existing message with his own content.
The text was updated successfully, but these errors were encountered: