123456789101112131415161718192021222324252627282930313233343536373839 |
- import { getRepository } from "typeorm";
- import { DeadChatReply } from "@shared/db/entity/DeadChatReply";
- import { CommandSet, Action, ActionType } from "src/model/command";
- import { Message } from "discord.js";
- const triggers = [
- "dead server",
- "dead chat",
- "ded chat",
- "ded server"
- ];
- @CommandSet
- export class DeadChat {
- @Action(ActionType.MESSAGE)
- async onMessage(actionsDone: boolean, msg: Message, content: string): Promise<boolean> {
- if (actionsDone)
- return false;
- const lowerContent = content.toLowerCase();
- if (!triggers.some(s => lowerContent.includes(s)))
- return false;
- const repo = getRepository(DeadChatReply);
- const reply = await repo.query(` select message
- from dead_chat_reply
- order by random()
- limit 1`) as DeadChatReply[];
- if (reply.length == 0)
- return false;
- msg.channel.send(reply[0].message);
- return true;
- }
- }
|