generated from Baipyrus/DiscordJS-Template
Compare commits
4 Commits
9f3bceeade
...
ab6ca9edeb
Author | SHA1 | Date | |
---|---|---|---|
ab6ca9edeb | |||
064abe7e24 | |||
5c4192eb4b | |||
b99db199d7 |
@ -5,7 +5,7 @@ import { Message } from '../../../database.js';
|
||||
/**
|
||||
* Sends a `Message` in the current channel and registers for self roles.
|
||||
* @param {ChatInputCommandInteraction} interaction
|
||||
* @returns {string}
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
const createSelfRoles = async (interaction) => {
|
||||
const { options, channel } = interaction;
|
||||
@ -14,9 +14,11 @@ const createSelfRoles = async (interaction) => {
|
||||
const text = options.getString('text');
|
||||
const id = (await channel.send(text)).id;
|
||||
|
||||
// Reply and delete to acknowledge command
|
||||
await interaction.deferReply();
|
||||
await interaction.deleteReply();
|
||||
// Reply successfully to acknowledge command
|
||||
await interaction.reply({
|
||||
content: `Successfully sent message! Add roles to it with reference ID '${id}'.`,
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
return id;
|
||||
};
|
||||
|
@ -33,7 +33,13 @@ export async function execute(reaction, user) {
|
||||
// Deny if unregistered
|
||||
if (rep === null) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ const saveMessageData = async (id, role, emoji) => {
|
||||
);
|
||||
|
||||
// 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*):/, ":_:") });
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user