Compare commits

...

4 Commits

Author SHA1 Message Date
ab6ca9edeb forced reaction remove error handling 2024-02-16 18:26:25 +01:00
064abe7e24 save emoji identifier without name 2024-02-16 18:26:00 +01:00
5c4192eb4b reply and provide id 2024-02-16 17:37:53 +01:00
b99db199d7 fixed jsdoc type error 2024-02-13 20:29:02 +01:00
3 changed files with 14 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import { Message } from '../../../database.js';
/** /**
* Sends a `Message` in the current channel and registers for self roles. * Sends a `Message` in the current channel and registers for self roles.
* @param {ChatInputCommandInteraction} interaction * @param {ChatInputCommandInteraction} interaction
* @returns {string} * @returns {Promise<string>}
*/ */
const createSelfRoles = async (interaction) => { const createSelfRoles = async (interaction) => {
const { options, channel } = interaction; const { options, channel } = interaction;
@ -14,9 +14,11 @@ const createSelfRoles = async (interaction) => {
const text = options.getString('text'); const text = options.getString('text');
const id = (await channel.send(text)).id; const id = (await channel.send(text)).id;
// Reply and delete to acknowledge command // Reply successfully to acknowledge command
await interaction.deferReply(); await interaction.reply({
await interaction.deleteReply(); content: `Successfully sent message! Add roles to it with reference ID '${id}'.`,
ephemeral: true
});
return id; return id;
}; };

View File

@ -33,7 +33,13 @@ export async function execute(reaction, user) {
// Deny if unregistered // Deny if unregistered
if (rep === null) { if (rep === null) {
// Remove reaction and quit // Remove reaction and quit
await reaction.remove(); try {
reaction.remove();
} catch (error) {
// Missing permissions
console.error(error)
await user.send('Unable to remove reaction. Please contact server staff.');
}
return; return;
} }

View File

@ -66,7 +66,7 @@ const saveMessageData = async (id, role, emoji) => {
); );
// Create database entry for pair // Create database entry for pair
await RoleEmojiPair.create({ message: id, role: role.id, emoji }); await RoleEmojiPair.create({ message: id, role: role.id, emoji: emoji.replace(/:(\s*[^:]*\s*):/, ":_:") });
}; };
/** /**