reaction_roles: fix !reaction_roles matching emojis/roles incorrectly; add progress message
This commit is contained in:
parent
862a9fdb02
commit
25b23c61ef
1 changed files with 6 additions and 3 deletions
|
@ -1,9 +1,9 @@
|
||||||
import { reactionRolesCmd, TReactionRolePair } from "../types";
|
import { reactionRolesCmd, TReactionRolePair } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
import { RecoverablePluginError, ERRORS } from "src/RecoverablePluginError";
|
import { RecoverablePluginError, ERRORS } from "src/RecoverablePluginError";
|
||||||
import { canUseEmoji } from "src/utils";
|
import { canUseEmoji, noop } from "../../../utils";
|
||||||
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
||||||
|
|
||||||
const CLEAR_ROLES_EMOJI = "❌";
|
const CLEAR_ROLES_EMOJI = "❌";
|
||||||
|
@ -46,7 +46,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
||||||
const emojiRolePairs: TReactionRolePair[] = args.reactionRolePairs
|
const emojiRolePairs: TReactionRolePair[] = args.reactionRolePairs
|
||||||
.trim()
|
.trim()
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map(v => v.split(/(\s|[=,])+/).map(v => v.trim())) // tslint:disable-line
|
.map(v => v.split(/[\s=,]+/).map(v => v.trim())) // tslint:disable-line
|
||||||
.map(
|
.map(
|
||||||
(pair): TReactionRolePair => {
|
(pair): TReactionRolePair => {
|
||||||
const customEmojiMatch = pair[0].match(/^<a?:(.*?):(\d+)>$/);
|
const customEmojiMatch = pair[0].match(/^<a?:(.*?):(\d+)>$/);
|
||||||
|
@ -93,6 +93,8 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const progressMessage = msg.channel.createMessage("Adding reaction roles...");
|
||||||
|
|
||||||
// Save the new reaction roles to the database
|
// Save the new reaction roles to the database
|
||||||
for (const pair of emojiRolePairs) {
|
for (const pair of emojiRolePairs) {
|
||||||
await pluginData.state.reactionRoles.add(channel.id, targetMessage.id, pair[0], pair[1], args.exclusive);
|
await pluginData.state.reactionRoles.add(channel.id, targetMessage.id, pair[0], pair[1], args.exclusive);
|
||||||
|
@ -103,5 +105,6 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
||||||
await applyReactionRoleReactionsToMessage(pluginData, targetMessage.channel.id, targetMessage.id, reactionRoles);
|
await applyReactionRoleReactionsToMessage(pluginData, targetMessage.channel.id, targetMessage.id, reactionRoles);
|
||||||
|
|
||||||
sendSuccessMessage(pluginData, msg.channel, "Reaction roles added");
|
sendSuccessMessage(pluginData, msg.channel, "Reaction roles added");
|
||||||
|
(await progressMessage).delete().catch(noop);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue