implement self roles command

This commit is contained in:
Baipyrus 2024-01-29 02:10:16 +01:00
parent 1f5f5621c3
commit e41afe0ada
2 changed files with 50 additions and 9 deletions

View File

@ -1,9 +0,0 @@
import { SlashCommandBuilder } from 'discord.js';
export const data = new SlashCommandBuilder()
.setName('self_roles')
.setDescription('Manages reactions for self roles.');
export async function execute(interaction) {
await interaction
.reply('Unimplemented!');
}

View File

@ -0,0 +1,50 @@
import { SlashCommandBuilder } from 'discord.js';
export const data = new SlashCommandBuilder()
.setName('self_roles')
.setDescription('Manages reactions for self roles.')
.addSubcommand(subcommand =>
subcommand
.setName('create')
.setDescription('Creates new message in channel.')
.addStringOption(option =>
option
.setRequired(true)
.setName('text')
.setDescription('The text to be displayed in the message.')))
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('Adds functionality to an existing message.')
.addStringOption(option =>
option
.setName('id')
.setRequired(true)
.setDescription('The ID to reference the message to be used.')));
export async function execute(interaction) {
const channel = interaction.channel;
let message = null;
switch (interaction.options.getSubcommand()) {
case 'create':
// Create message with text input
const text = interaction.options.getString('text');
message = await channel.send(text);
// Reply and delete to acknowledge command
interaction.deferReply();
interaction.deleteReply();
break;
case 'add':
// Get message by id
const id = interaction.options.getString('id');
message = await channel.messages.fetch(id);
// Reply to acknowledge command
await interaction.reply({
content: 'Successfully fetched message!',
ephemeral: true,
});
break;
}
console.debug(`[DEBUG] Message ID: '${message.id}'.`);
}