From 19d23fa0411a4dfa844e6ca7b34a359a6368f3c9 Mon Sep 17 00:00:00 2001 From: taranvohra Date: Mon, 8 Apr 2024 21:53:56 +0530 Subject: [PATCH] troll --- src/features/troll.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/features/troll.ts diff --git a/src/features/troll.ts b/src/features/troll.ts new file mode 100644 index 00000000..35482ce2 --- /dev/null +++ b/src/features/troll.ts @@ -0,0 +1,32 @@ +import { ChannelType } from "discord.js"; +import { isStaff } from "../helpers/discord"; +import { ChannelHandlers } from "../types"; + +const troll: ChannelHandlers = { + handleMessage: async ({ msg: maybeMessage, bot }) => { + const msg = maybeMessage.partial + ? await maybeMessage.fetch() + : maybeMessage; + + if ( + msg.guild || + !isStaff(msg.member) || + !msg.content.startsWith("skillissue") + ) + return; + + const [, messageLink] = msg.content.split(" "); + const [guildId, channelId, messageId] = new URL(messageLink).pathname + .split("/") + .slice(-3); + + const guild = await bot.guilds.fetch(guildId); + const channel = await guild.channels.fetch(channelId); + if (channel && channel.type === ChannelType.GuildText) { + const message = await channel.messages.fetch(messageId); + await message.reply("skill issue"); + } + }, +}; + +export default troll;