Updated packages, added report command.
Some checks reported warnings
prisma-migrate / install (push) Has been cancelled
prisma-migrate / generate (push) Has been cancelled
prisma-migrate / migrate (push) Has been cancelled

Closes #5

Signed-off-by: Louis Hollingworth <louis@hollingworth.nl>
This commit is contained in:
Louis Hollingworth 2023-07-22 16:01:09 +01:00
parent f917564a83
commit 6fb7a492db
Signed by: lucxjo
GPG key ID: A11415CB3DC7809B
3 changed files with 153 additions and 98 deletions

55
src/commands/report.ts Normal file
View file

@ -0,0 +1,55 @@
import {
ApplicationCommandOptionType,
Client,
CommandInteraction,
GuildMember,
TextChannel,
User,
} from "discord.js";
import { Discord, Slash, SlashOption } from "discordx";
import { prisma } from "../main.js";
@Discord()
export class Report {
@Slash({ description: "Report a user to the guild staff", name: "report" })
async report(
@SlashOption({
required: true,
description: "The user to report",
name: "user",
type: ApplicationCommandOptionType.User,
})
user: GuildMember | User,
@SlashOption({
required: true,
description: "Why you are reporting this user",
name: "reason",
type: ApplicationCommandOptionType.String,
})
reason: string,
interaction: CommandInteraction,
client: Client
) {
if (interaction.guild) {
const guild = await prisma.guild.findUnique({
where: {
id: interaction.guild.id,
},
});
if (guild && guild.reports_channel_id) {
await client.channels
.fetch(guild!.reports_channel_id!)
.then((channel) => {
if (channel!.isTextBased()) {
const ct = channel as TextChannel;
ct.send(`${interaction.user} reported ${user} for: ${reason}`);
}
});
}
await interaction.reply({ content: "Report sent!", ephemeral: true });
return;
}
await interaction.reply("You need to be in a guild to use this command");
}
}