generated from Baipyrus/DiscordJS-Template
implemented context menu command for registering self roles
This commit is contained in:
parent
124e5afe5a
commit
d7409ed0f7
29
commands/admin/ctx_self_roles.js
Normal file
29
commands/admin/ctx_self_roles.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { Message } from '../../database.js';
|
||||||
|
import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
|
export const data = new ContextMenuCommandBuilder()
|
||||||
|
.setName('Register self roles')
|
||||||
|
.setType(ApplicationCommandType.Message);
|
||||||
|
export async function execute(interaction) {
|
||||||
|
const id = interaction.targetMessage.id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create database entry
|
||||||
|
Message.create({ id });
|
||||||
|
|
||||||
|
// Reply successfully to acknowledge command
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Successfully saved data from message!',
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.info(`[INFO] New self roles on message with ID: '${id}'.`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
// Reply failed to acknowledge command
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Failed to save data from message!',
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user