mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Rename Events and files to prevent ambiguity and order availablePlugins
This commit is contained in:
parent
f324dfc227
commit
0bc7dc17b7
13 changed files with 59 additions and 65 deletions
43
backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts
Normal file
43
backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { autoReactionsEvt } from "../types";
|
||||
import { isDiscordRESTError } from "src/utils";
|
||||
import { logger } from "knub";
|
||||
import { LogType } from "src/data/LogType";
|
||||
|
||||
export const AddReactionsEvt = autoReactionsEvt({
|
||||
event: "messageCreate",
|
||||
allowOutsideOfGuild: false,
|
||||
|
||||
async listener(meta) {
|
||||
const pluginData = meta.pluginData;
|
||||
const msg = meta.args.message;
|
||||
|
||||
const autoReaction = await pluginData.state.autoReactions.getForChannel(msg.channel.id);
|
||||
if (!autoReaction) return;
|
||||
|
||||
for (const reaction of autoReaction.reactions) {
|
||||
try {
|
||||
await msg.addReaction(reaction);
|
||||
} catch (e) {
|
||||
if (isDiscordRESTError(e)) {
|
||||
logger.warn(
|
||||
`Could not apply auto-reaction to ${msg.channel.id}/${msg.id} in guild ${pluginData.guild.name} (${pluginData.guild.id}) (error code ${e.code})`,
|
||||
);
|
||||
|
||||
if (e.code === 10008) {
|
||||
pluginData.state.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.`,
|
||||
});
|
||||
} else {
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
body: `Could not apply auto-reactions in <#${msg.channel.id}> for message \`${msg.id}\`. Error code ${e.code}.`,
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue