Converted main codebase to typescript

Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
2023-12-28 13:17:57 +01:00
parent 1d9ded82a4
commit 68fde04bbb
122 changed files with 14230 additions and 1834 deletions

68
src/commands/remove.ts Normal file
View File

@@ -0,0 +1,68 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import { color } from "../../config/options.json"
import waitinglistSchema = require("../schemas/waitinglistSchema")
import { Command } from "../interfaces"
export = {
name: "remove",
description: "Remove a person on the waiting list.",
type: "slash",
dev: false,
public: false,
data: new SlashCommandBuilder()
.setName("remove")
.setDescription("Remove a person on the waiting list.")
.addUserOption(option =>
option
.setName("user")
.setDescription("The user to remove.")
.setRequired(true)
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("The reason for removing the user.")
.setRequired(false)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getUser("user")!
const reason = interaction.options.getString("reason") ?? "No reason provided."
const mod = interaction.user!
const embedColor = Number(color.replace("#", "0x"))
const waitinglist = await waitinglistSchema.findOne({ UserID: user.id })
if (!waitinglist) {
await interaction.editReply({
embeds: [{
description: userMention(user.id) + " is not on the waiting list.",
color: embedColor
}]
})
return
}
await waitinglistSchema.findOneAndDelete({ UserID: user.id })
await interaction.editReply({
embeds: [{
description: userMention(user.id) + " has been removed from the waiting list.\n" +
"**Reason:** `" + reason + "`\n" +
"**Moderator:** " + userMention(mod.id),
color: embedColor,
footer: {
text: "User ID: " + user.id,
icon_url: user.displayAvatarURL({ forceStatic: false })
},
timestamp: new Date().toISOString()
}]
})
}
} as Command