|
@@ -0,0 +1,31 @@
|
|
|
|
+import { CommandSet, Action, ActionType } from "src/model/command";
|
|
|
|
+import { Message } from "discord.js";
|
|
|
|
+import { getRepository } from "typeorm";
|
|
|
|
+import { RandomMessageReaction } from "@shared/db/entity/RandomMesssageReaction";
|
|
|
|
+import { client } from "src/client";
|
|
|
|
+
|
|
|
|
+@CommandSet
|
|
|
|
+export class RandomReact {
|
|
|
|
+ @Action(ActionType.MESSAGE)
|
|
|
|
+ async showHelp(actionsDone: boolean, msg: Message) {
|
|
|
|
+ if(actionsDone)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ let repo = getRepository(RandomMessageReaction);
|
|
|
|
+
|
|
|
|
+ let reactInfo = await repo.findOne({ where: { userId: msg.author.id } });
|
|
|
|
+
|
|
|
|
+ if(!reactInfo)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ let emote = client.emojis.get(reactInfo.reactionEmoteId);
|
|
|
|
+
|
|
|
|
+ if(!emote)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if(Math.random() < reactInfo.reactProbability)
|
|
|
|
+ await msg.react(emote);
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|