|
@@ -2,9 +2,10 @@ import { client } from "../client";
|
|
|
import { getRepository } from "typeorm";
|
|
|
import { KnownUser } from "@shared/db/entity/KnownUser";
|
|
|
import { ReactionType, ReactionEmote } from "@shared/db/entity/ReactionEmote";
|
|
|
-import { Message, User, PartialUser, MessageReaction } from "discord.js";
|
|
|
+import { Message, User, PartialUser, MessageReaction as DiscordMessageReaction } from "discord.js";
|
|
|
import { logger } from "src/logging";
|
|
|
import { Command, ICommandData, Event, BotEventData, Plugin } from "src/model/plugin";
|
|
|
+import { MessageReaction } from "@shared/db/entity/MessageReaction";
|
|
|
|
|
|
const pattern = /^react to\s+"([^"]+)"\s+with\s+<:[^:]+:([^>]+)>$/i;
|
|
|
|
|
@@ -24,14 +25,14 @@ async function getRandomEmotes(allowedTypes: ReactionType[], limit: number) {
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
-const REACT_PROBABILITY = 0.3;
|
|
|
-
|
|
|
@Plugin
|
|
|
export class ReactCommands {
|
|
|
|
|
|
+ private REACT_PROBABILITY = 0.3;
|
|
|
+
|
|
|
@Event("messageReactionAdd")
|
|
|
- async randomReact(data: BotEventData, reaction: MessageReaction, user: User | PartialUser): Promise<void> {
|
|
|
- if (Math.random() <= REACT_PROBABILITY && !user.bot) {
|
|
|
+ async randomReact(data: BotEventData, reaction: DiscordMessageReaction, user: User | PartialUser): Promise<void> {
|
|
|
+ if (Math.random() <= this.REACT_PROBABILITY && !user.bot) {
|
|
|
logger.verbose(`Reacting to message ${reaction.message.id} because user ${user.tag} reacted to it`);
|
|
|
reaction.message.react(reaction.emoji);
|
|
|
}
|