Fix error in AutoReactions error handling (yo dawg)

This commit is contained in:
Dragory 2020-07-30 15:50:30 +03:00
parent dbc083f6a9
commit 80b13fa20b
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 6 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildAutoReactions } from "src/data/GuildAutoReactions"; import { GuildAutoReactions } from "src/data/GuildAutoReactions";
import { AddReactionsEvt } from "./events/AddReactionsEvt"; import { AddReactionsEvt } from "./events/AddReactionsEvt";
import { trimPluginDescription } from "../../utils"; import { trimPluginDescription } from "../../utils";
import { LogsPlugin } from "../Logs/LogsPlugin";
const defaultOptions: PluginOptions<AutoReactionsPluginType> = { const defaultOptions: PluginOptions<AutoReactionsPluginType> = {
config: { config: {
@ -31,6 +32,7 @@ export const AutoReactionsPlugin = zeppelinPlugin<AutoReactionsPluginType>()("au
`), `),
}, },
dependencies: [LogsPlugin],
configSchema: ConfigSchema, configSchema: ConfigSchema,
defaultOptions, defaultOptions,

View file

@ -2,6 +2,7 @@ import { autoReactionsEvt } from "../types";
import { isDiscordRESTError } from "src/utils"; import { isDiscordRESTError } from "src/utils";
import { LogType } from "src/data/LogType"; import { LogType } from "src/data/LogType";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { LogsPlugin } from "../../Logs/LogsPlugin";
export const AddReactionsEvt = autoReactionsEvt({ export const AddReactionsEvt = autoReactionsEvt({
event: "messageCreate", event: "messageCreate",
@ -23,12 +24,13 @@ export const AddReactionsEvt = autoReactionsEvt({
`Could not apply auto-reaction to ${msg.channel.id}/${msg.id} in guild ${pluginData.guild.name} (${pluginData.guild.id}) (error code ${e.code})`, `Could not apply auto-reaction to ${msg.channel.id}/${msg.id} in guild ${pluginData.guild.name} (${pluginData.guild.id}) (error code ${e.code})`,
); );
const logs = pluginData.getPlugin(LogsPlugin);
if (e.code === 10008) { if (e.code === 10008) {
pluginData.state.logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
body: `Could not apply auto-reactions in <#${msg.channel.id}> for message \`${msg.id}\`. Make sure nothing is deleting the message before the reactions are applied.`, body: `Could not apply auto-reactions in <#${msg.channel.id}> for message \`${msg.id}\`. Make sure nothing is deleting the message before the reactions are applied.`,
}); });
} else { } else {
pluginData.state.logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
body: `Could not apply auto-reactions in <#${msg.channel.id}> for message \`${msg.id}\`. Error code ${e.code}.`, body: `Could not apply auto-reactions in <#${msg.channel.id}> for message \`${msg.id}\`. Error code ${e.code}.`,
}); });
} }