Add a system message return to `disnake.Message.pin()`
wkmeupinside opened this issue · 2 comments
Summary
When a message is pinned to a channel, a system message is sent from Discord that this message has been pinned. It would be great if the method disnake.Message.pin()
returned this message.
What is the feature request for?
The core library
The Problem
I want the bot to delete the Discord system message after pinning another message, but to implement this I have to use:
async for message in channel.history(limit=1):
await message.delete()
Because of this implementation, the bot can delete not a system message, but a completely different one if many users send many messages at one time.
In case disnake.Message.pin()
will return a system message, then it can be safely deleted by simply using:
msg = await message.pin()
await msg.delete()
The system message:
The Ideal Solution
Just return the system message if possible.
The Current Solution
No response
Additional Context
No response
This isn't something that can be implemented in the library - the API endpoint used for pinning messages does not return the system message: https://discord.com/developers/docs/resources/channel#pin-message
To avoid deleting unrelated messages in your case, consider checking message.type == disnake.MessageType.pins_add
while iterating through channel history.
This isn't something that can be implemented in the library - the API endpoint used for pinning messages does not return the system message: https://discord.com/developers/docs/resources/channel#pin-message To avoid deleting unrelated messages in your case, consider checking
message.type == disnake.MessageType.pins_add
while iterating through channel history.
Thank you