Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -3,6 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
import { isDiscordRESTError } from "../../../utils";
|
||||
import { Message } from "discord.js";
|
||||
|
||||
export const ClearReactionRolesCmd = reactionRolesCmd({
|
||||
trigger: "reaction_roles clear",
|
||||
|
@ -21,9 +22,9 @@ export const ClearReactionRolesCmd = reactionRolesCmd({
|
|||
|
||||
pluginData.state.reactionRoles.removeFromMessage(args.message.messageId);
|
||||
|
||||
let targetMessage: Message<TextChannel>;
|
||||
let targetMessage: Message;
|
||||
try {
|
||||
targetMessage = await args.message.channel.getMessage(args.message.messageId);
|
||||
targetMessage = await args.message.channel.messages.fetch(args.message.messageId);
|
||||
} catch (err) {
|
||||
if (isDiscordRESTError(err) && err.code === 50001) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Missing access to the specified message");
|
||||
|
@ -33,7 +34,7 @@ export const ClearReactionRolesCmd = reactionRolesCmd({
|
|||
throw err;
|
||||
}
|
||||
|
||||
await targetMessage.removeReactions();
|
||||
await targetMessage.reactions.removeAll();
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel, "Reaction roles cleared");
|
||||
},
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { reactionRolesCmd, TReactionRolePair } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
import { RecoverablePluginError, ERRORS } from "../../../RecoverablePluginError";
|
||||
import { canUseEmoji, isDiscordRESTError, isValidEmoji, noop, trimPluginDescription } from "../../../utils";
|
||||
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||
|
@ -41,7 +39,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
|||
|
||||
let targetMessage;
|
||||
try {
|
||||
targetMessage = await args.message.channel.getMessage(args.message.messageId).catch(noop);
|
||||
targetMessage = await args.message.channel.messages.fetch(args.message.messageId).catch(noop);
|
||||
} catch (e) {
|
||||
if (isDiscordRESTError(e)) {
|
||||
sendErrorMessage(pluginData, msg.channel, `Error ${e.code} while getting message: ${e.message}`);
|
||||
|
@ -96,13 +94,13 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
if (!pluginData.guild.roles.has(pair[1])) {
|
||||
if (!pluginData.guild.roles.cache.has(pair[1])) {
|
||||
sendErrorMessage(pluginData, msg.channel, `Unknown role ${pair[1]}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const progressMessage = msg.channel.createMessage("Adding reaction roles...");
|
||||
const progressMessage = msg.channel.send("Adding reaction roles...");
|
||||
|
||||
// Save the new reaction roles to the database
|
||||
for (const pair of emojiRolePairs) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue