add delete button for message link embeds (#117)
Signed-off-by: IThundxr <contact@ithundxr.dev>
This commit is contained in:
parent
8a61d99323
commit
569a08c95d
7 changed files with 27 additions and 8 deletions
2
.env.example
Normal file
2
.env.example
Normal file
|
@ -0,0 +1,2 @@
|
|||
DISCORD_TOKEN=
|
||||
DISCORD_APP=
|
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base",
|
||||
"config:js-app"
|
||||
]
|
||||
"extends": ["config:base", "config:js-app"]
|
||||
}
|
||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -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;
|
||||
|
||||
|
|
|
@ -79,7 +79,11 @@ export async function expandDiscordLink(message: Message): Promise<void> {
|
|||
new ButtonBuilder()
|
||||
.setLabel('Jump to original message')
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setURL(messageToShow.url)
|
||||
.setURL(messageToShow.url),
|
||||
new ButtonBuilder()
|
||||
.setCustomId('delete-message')
|
||||
.setLabel('Delete')
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
);
|
||||
|
||||
await message.reply({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue