Skip to content

Commit

Permalink
add message remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
LarmuseauNiels committed Apr 19, 2023
1 parent 250a4cb commit 1a22233
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions interactions/contextmenus/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const {
ContextMenuCommandBuilder,
ApplicationCommandType,
EmbedBuilder,
PermissionFlagsBits,
} = require("discord.js");
module.exports = {
name: "info",
data: new ContextMenuCommandBuilder()
.setName("remove")
.setType(ApplicationCommandType.Message)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
//remove the message
interaction.channel.messages.fetch(interaction.targetId).then((message) => {
const { author, content, channel } = message;
const { user: interactionUser } = interaction;

const removedMessageEmbed = new EmbedBuilder()
.setTitle("Message removed")
.setDescription(
`${author.displayName}'s message has been removed by ${interactionUser.displayName}`
)
.addFields(
{ name: "Message", value: content, inline: false },
{ name: "Channel", value: channel.name, inline: false }
)
.setColor("#FF0000")
.setTimestamp();

global.client.logChannel.send({ embeds: [removedMessageEmbed] });

const userMessageEmbed = new EmbedBuilder()
.setTitle("Your message has been removed")
.setDescription(
`Your message has been removed by ${interactionUser.displayName}`
)
.addFields(
{ name: "Message", value: content, inline: false },
{ name: "Channel", value: channel.name, inline: false }
)
.setColor("#FF0000")
.setTimestamp();

author.send({ embeds: [userMessageEmbed] });

message.delete();
});
//send a message to the channel
interaction.reply({ content: "Message removed", ephemeral: true });
},
isGuild: true,
};

0 comments on commit 1a22233

Please sign in to comment.