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;