feat(arabot): add old style of running sus command

This commit is contained in:
Anthony 2022-09-09 00:43:13 +01:00
parent 644b3ea3cd
commit 88086a1f31

View File

@ -17,10 +17,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior, Args } from '@sapphire/framework';
import { import {
MessageEmbed, MessageActionRow, MessageButton, Constants, ButtonInteraction, MessageEmbed, MessageActionRow, MessageButton, Constants, ButtonInteraction,
} from 'discord.js'; } from 'discord.js';
import type { Message, GuildMember } from 'discord.js';
import { PrismaClient } from '@prisma/client'; import { PrismaClient } from '@prisma/client';
import { isMessageInstance } from '@sapphire/discord.js-utilities'; import { isMessageInstance } from '@sapphire/discord.js-utilities';
import { addExistingUser, userExists } from '../../utils/dbExistingUser'; import { addExistingUser, userExists } from '../../utils/dbExistingUser';
@ -561,6 +562,49 @@ class SusCommand extends Command {
// Remove sus role from the user // Remove sus role from the user
await userGuildMember!.roles.remove(IDs.roles.restrictions.sus); await userGuildMember!.roles.remove(IDs.roles.restrictions.sus);
} }
// Non Application Command method of adding a sus note
public async messageRun(message: Message, args: Args) {
// Get arguments
let user: GuildMember;
try {
user = await args.pick('member');
} catch {
await message.react('❌');
await message.reply('User to give sus note to was not provided!');
return;
}
const note = args.finished ? null : await args.rest('string');
const mod = message.member;
if (note === null) {
await message.react('❌');
await message.reply('No sus note was provided!');
return;
}
if (mod === null) {
await message.react('❌');
await message.reply('Moderator not found! Try again or contact a developer!');
return;
}
// Check if user and mod are on the database
if (!await userExists(user)) {
await addExistingUser(user);
}
if (!await userExists(mod!)) {
await addExistingUser(mod!);
}
await addToDatabase(user.id, mod.id, note);
// Give the user the sus role they don't already have the sus note
if (!user.roles.cache.has(IDs.roles.restrictions.sus)) {
await user!.roles.add(IDs.roles.restrictions.sus);
}
await message.react('✅');
}
} }
export default SusCommand; export default SusCommand;