2024-02-04 23:16:52 +00:00
|
|
|
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
|
2024-02-05 02:01:48 +00:00
|
|
|
await Message.create({ id });
|
2024-02-04 23:16:52 +00:00
|
|
|
|
|
|
|
// 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,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|