Finish preliminary rework, ready to test

This commit is contained in:
Dark 2021-06-02 04:07:50 +02:00
parent 57893e7f76
commit d0a1beb809
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
177 changed files with 854 additions and 707 deletions

View file

@ -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");
},

View file

@ -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) {