From a047ade28f0cf4992708d2df9a3237f17840f7a5 Mon Sep 17 00:00:00 2001 From: smyalygames Date: Tue, 7 Feb 2023 23:35:30 +0000 Subject: [PATCH] feat(arabot): add suggestions handler --- src/listeners/suggestions.ts | 62 ++++++++++++++++++++++++++++++++++++ src/utils/devIDs.ts | 2 ++ src/utils/ids.ts | 2 ++ 3 files changed, 66 insertions(+) create mode 100644 src/listeners/suggestions.ts diff --git a/src/listeners/suggestions.ts b/src/listeners/suggestions.ts new file mode 100644 index 0000000..0e0db02 --- /dev/null +++ b/src/listeners/suggestions.ts @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + Animal Rights Advocates Discord Bot + Copyright (C) 2023 Anthony Berg + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import { Listener } from '@sapphire/framework'; +import { EmbedBuilder } from 'discord.js'; +import type { Message } from 'discord.js'; +import IDs from '#utils/ids'; + +export class Suggestions extends Listener { + public constructor(context: Listener.Context, options: Listener.Options) { + super(context, { + ...options, + event: 'messageCreate', + }); + } + + public async run(message: Message) { + if (message.channelId !== IDs.channels.information.suggestions) { + return; + } + + const mailbox = await this.container.client.channels.cache + .get(IDs.channels.staff.mailbox); + + if (mailbox === undefined + || !mailbox.isTextBased()) { + this.container.logger.error('Mailbox is not a TextBased channel or is undefined'); + return; + } + + const suggestion = new EmbedBuilder() + .setColor('#FFFFFF') + .setAuthor({ name: `Suggestion from ${message.author.tag}`, iconURL: `${message.author.avatarURL()}` }) + .addFields( + { name: 'Suggestion:', value: message.content }, + ) + .setTimestamp(); + + const sent = await mailbox.send({ embeds: [suggestion], content: message.author.toString() }); + await message.delete(); + + await sent.react('👍'); + await sent.react('👎'); + await sent.react('<:catshrug:917505035196313671>'); + } +} diff --git a/src/utils/devIDs.ts b/src/utils/devIDs.ts index 2c591f0..093c743 100644 --- a/src/utils/devIDs.ts +++ b/src/utils/devIDs.ts @@ -68,9 +68,11 @@ const devIDs = { news: '999431676058927247', conduct: '999431676058927248', roles: '999431676058927250', + suggestions: '999431676058927251', }, staff: { coordinators: '999431676058927254', + mailbox: '999431676289622182', standup: '999431676289622183', verifiers: '999431677006860411', }, diff --git a/src/utils/ids.ts b/src/utils/ids.ts index dfeb3e8..0b1d40b 100644 --- a/src/utils/ids.ts +++ b/src/utils/ids.ts @@ -71,9 +71,11 @@ let IDs = { news: '866000393259319306', conduct: '990728521531920385', roles: '990761562199457813', + suggestions: '831940452609556511', }, staff: { coordinators: '1006240682505142354', + mailbox: '972364104838824116', standup: '996009201237233684', verifiers: '873215538627756072', },