prepare role-emoji-pair adding
This commit is contained in:
parent
e41afe0ada
commit
7126d34866
@ -14,37 +14,80 @@ export const data = new SlashCommandBuilder()
|
|||||||
.setDescription('The text to be displayed in the message.')))
|
.setDescription('The text to be displayed in the message.')))
|
||||||
.addSubcommand(subcommand =>
|
.addSubcommand(subcommand =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName('add')
|
.setName('register')
|
||||||
.setDescription('Adds functionality to an existing message.')
|
.setDescription('Registers an existing message.')
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
option
|
option
|
||||||
.setName('id')
|
.setName('id')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.setDescription('The ID to reference the message to be used.')));
|
.setDescription('The ID to reference the message to be used.')))
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('add')
|
||||||
|
.setDescription('Add a role-emoji-pair to a message.')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName('id')
|
||||||
|
.setRequired(true)
|
||||||
|
.setDescription('The ID to reference the message to be used.'))
|
||||||
|
.addRoleOption(option =>
|
||||||
|
option
|
||||||
|
.setName('role')
|
||||||
|
.setRequired(true)
|
||||||
|
.setDescription('The role be assigned to.'))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName('emoji')
|
||||||
|
.setRequired(true)
|
||||||
|
.setDescription('The emoji to be reacted with.')));
|
||||||
export async function execute(interaction) {
|
export async function execute(interaction) {
|
||||||
const channel = interaction.channel;
|
const channel = interaction.channel;
|
||||||
let message = null;
|
|
||||||
|
|
||||||
|
let createNew = false;
|
||||||
|
let id = interaction.options.getString('id');
|
||||||
switch (interaction.options.getSubcommand()) {
|
switch (interaction.options.getSubcommand()) {
|
||||||
case 'create':
|
case 'create':
|
||||||
// Create message with text input
|
// Create message with text input
|
||||||
const text = interaction.options.getString('text');
|
const text = interaction.options.getString('text');
|
||||||
message = await channel.send(text);
|
id = (await channel.send(text)).id;
|
||||||
// Reply and delete to acknowledge command
|
// Reply and delete to acknowledge command
|
||||||
interaction.deferReply();
|
interaction.deferReply();
|
||||||
interaction.deleteReply();
|
interaction.deleteReply();
|
||||||
|
// Flag to create new database entry
|
||||||
|
createNew = true;
|
||||||
|
break;
|
||||||
|
case 'register':
|
||||||
|
try {
|
||||||
|
// Get message by id
|
||||||
|
await channel.messages.fetch(id);
|
||||||
|
// Reply successfully to acknowledge command
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Successfully fetched message!',
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
// Flag to create new database entry
|
||||||
|
createNew = true;
|
||||||
|
} catch (_) {
|
||||||
|
// Reply failed to acknowledge command
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Failed to fetch message!',
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
// Get message by id
|
const role = interaction.options.getRole('role');
|
||||||
const id = interaction.options.getString('id');
|
const emoji = interaction.options.getString('emoji');
|
||||||
message = await channel.messages.fetch(id);
|
|
||||||
// Reply to acknowledge command
|
// Reply successfully to acknowledge command
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'Successfully fetched message!',
|
content: 'Added new entry for self roles!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
console.debug(`[DEBUG] Added new entry to get role with ID '${role.id}' using '${emoji}'.`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug(`[DEBUG] Message ID: '${message.id}'.`);
|
if (createNew)
|
||||||
|
console.debug(`[DEBUG] New self roles on message with ID: '${id}'.`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user