generated from lucxjo/template
Updated packages, added report command.
Closes #5 Signed-off-by: Louis Hollingworth <louis@hollingworth.nl>
This commit is contained in:
parent
f917564a83
commit
6fb7a492db
3 changed files with 153 additions and 98 deletions
55
src/commands/report.ts
Normal file
55
src/commands/report.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue