add delete button for message link embeds (#117)

Signed-off-by: IThundxr <contact@ithundxr.dev>
This commit is contained in:
IThundxr 2023-03-09 20:33:14 -05:00 committed by GitHub
parent 8a61d99323
commit 569a08c95d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 8 deletions

View file

@ -98,6 +98,22 @@ client.once('ready', async () => {
});
client.on('interactionCreate', async (interaction) => {
if (interaction.isButton() && interaction.customId === 'delete-message') {
const messageRef = interaction.message.reference?.messageId;
if (messageRef) {
const msg = await interaction.message.channel.messages.fetch(messageRef);
if (interaction?.user === msg.author) {
await interaction.message.delete();
} else {
await interaction.reply({
content: 'You can only delete your own messages!',
ephemeral: true,
});
}
}
}
if (interaction.isChatInputCommand()) {
const { commandName } = interaction;