From 085e061f6085025770da83b433cef70ed43fe987 Mon Sep 17 00:00:00 2001 From: nick <62725534+nicklvh@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:21:15 +0000 Subject: [PATCH] fix: switch to double quotes and fix tsconfig.json --- .prettierrc | 4 - package.json | 9 +- src/commands/fun/cat.ts | 30 +-- src/commands/fun/coinflip.ts | 22 +-- src/commands/fun/dog.ts | 30 +-- src/commands/fun/duck.ts | 28 +-- src/commands/fun/rps.ts | 76 ++++---- src/commands/misc/avatar.ts | 68 +++---- src/commands/misc/serverinfo.ts | 78 ++++---- src/commands/misc/setnick.ts | 48 ++--- src/commands/misc/whois.ts | 26 +-- src/commands/moderation/ban.ts | 86 ++++---- src/commands/moderation/infractions.ts | 58 +++--- src/commands/moderation/kick.ts | 70 +++---- src/commands/moderation/mute.ts | 110 +++++------ src/commands/moderation/warn.ts | 70 +++---- src/commands/settings/settings.ts | 184 +++++++++--------- src/index.ts | 40 ++-- src/lib/api/decorators.ts | 22 +-- src/lib/api/index.ts | 2 +- src/lib/classes/ModerationManager.ts | 34 ++-- src/lib/classes/Utils.ts | 10 +- src/lib/classes/index.ts | 4 +- src/lib/types/Augments.d.ts | 11 +- src/lib/types/Util.ts | 42 ++-- src/lib/types/index.ts | 2 +- .../client/chatInputCommandDenied.ts | 8 +- src/listeners/client/ready.ts | 6 +- src/listeners/guild/channelCreate.ts | 20 +- src/listeners/guild/guildCreate.ts | 6 +- src/listeners/guild/guildDelete.ts | 6 +- src/listeners/guild/guildMemberAdd.ts | 18 +- src/listeners/guild/messageDelete.ts | 13 +- src/listeners/guild/messageUpdate.ts | 14 +- src/listeners/guild/roleCreate.ts | 20 +- src/listeners/guild/roleDelete.ts | 20 +- src/listeners/guild/roleUpdate.ts | 26 +-- src/routes/test.ts | 12 +- src/tsconfig.json | 16 -- tsconfig.base.json => tsconfig.json | 11 +- 40 files changed, 671 insertions(+), 689 deletions(-) delete mode 100644 .prettierrc delete mode 100644 src/tsconfig.json rename tsconfig.base.json => tsconfig.json (51%) diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 6e778b4..0000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "trailingComma": "all", - "singleQuote": true -} diff --git a/package.json b/package.json index 734a129..884983e 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Discord bot made in Sapphire, Discord.js and TypeScript", "main": "./dist/index.js", "scripts": { - "build": "tsc -b src", - "start": "tsc -b src && node ." + "build": "tsc src", + "start": "tsc src && node ." }, "private": true, "repository": { @@ -40,8 +40,5 @@ "prisma": "^5.7.1", "typescript": "^5.3.3" }, - "packageManager": "yarn@4.0.2", - "_moduleAliases": { - "@lib": "dist/lib" - } + "packageManager": "yarn@4.0.2" } diff --git a/src/commands/fun/cat.ts b/src/commands/fun/cat.ts index 6f4d096..0dc2eeb 100644 --- a/src/commands/fun/cat.ts +++ b/src/commands/fun/cat.ts @@ -1,26 +1,26 @@ -import { Command } from '@sapphire/framework'; -import { fetch, FetchResultTypes } from '@sapphire/fetch'; -import { EmbedBuilder } from 'discord.js'; -import type { APIPetResponse } from '#types/Util'; -import { ApplyOptions } from '@sapphire/decorators'; +import { Command } from "@sapphire/framework"; +import { fetch, FetchResultTypes } from "@sapphire/fetch"; +import { EmbedBuilder } from "discord.js"; +import type { APIPetResponse } from "#types/Util"; +import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ - name: 'cat', - description: 'shows a cat 😽', + name: "cat", + description: "shows a cat 😽", }) export class CatCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => - builder.setName(this.name).setDescription(this.description), + builder.setName(this.name).setDescription(this.description) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { const data = await fetch( - 'https://api.thecatapi.com/v1/images/search', - FetchResultTypes.JSON, + "https://api.thecatapi.com/v1/images/search", + FetchResultTypes.JSON ).catch((error) => this.container.logger.error(error)); const embed = new EmbedBuilder(); @@ -30,10 +30,10 @@ export class CatCommand extends Command { embeds: [ embed .setAuthor({ - name: 'Something went wrong! 😿', + name: "Something went wrong! 😿", iconURL: interaction.user.avatarURL()!, }) - .setColor('Red') + .setColor("Red") .setDescription(`Couldn't fetch a cat 😿\nTry again later!`), ], }); @@ -46,8 +46,8 @@ export class CatCommand extends Command { iconURL: interaction.user.avatarURL()!, }) .setImage(data[0].url) - .setColor('Blue') - .setFooter({ text: 'Powered by thecatapi.com' }), + .setColor("Blue") + .setFooter({ text: "Powered by thecatapi.com" }), ], }); } diff --git a/src/commands/fun/coinflip.ts b/src/commands/fun/coinflip.ts index cf59a7c..47cdf39 100644 --- a/src/commands/fun/coinflip.ts +++ b/src/commands/fun/coinflip.ts @@ -1,35 +1,35 @@ -import { Command } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; -import { EmbedBuilder } from 'discord.js'; +import { Command } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; +import { EmbedBuilder } from "discord.js"; @ApplyOptions({ - name: 'coinflip', - description: 'flip! shows heads or tails 🪙', + name: "coinflip", + description: "flip! shows heads or tails 🪙", }) export class CoinflipCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => - builder.setName(this.name).setDescription(this.description), + builder.setName(this.name).setDescription(this.description) ); } public override chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { return interaction.reply({ embeds: [ new EmbedBuilder() .setAuthor({ - name: 'Flip! 🪙', + name: "Flip! 🪙", iconURL: interaction.user.avatarURL()!, }) .addFields([ { - name: 'Result', - value: `\`${Math.random() > 0.5 ? 'Heads' : 'Tails'}\``, + name: "Result", + value: `\`${Math.random() > 0.5 ? "Heads" : "Tails"}\``, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], }); } diff --git a/src/commands/fun/dog.ts b/src/commands/fun/dog.ts index fa86ecb..4484721 100644 --- a/src/commands/fun/dog.ts +++ b/src/commands/fun/dog.ts @@ -1,26 +1,26 @@ -import { Command } from '@sapphire/framework'; -import { fetch, FetchResultTypes } from '@sapphire/fetch'; -import { EmbedBuilder } from 'discord.js'; -import type { APIPetResponse } from '#types/Util'; -import { ApplyOptions } from '@sapphire/decorators'; +import { Command } from "@sapphire/framework"; +import { fetch, FetchResultTypes } from "@sapphire/fetch"; +import { EmbedBuilder } from "discord.js"; +import type { APIPetResponse } from "#types/Util"; +import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ - name: 'dog', - description: 'shows a dog 🐶', + name: "dog", + description: "shows a dog 🐶", }) export class DogCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => - builder.setName(this.name).setDescription(this.description), + builder.setName(this.name).setDescription(this.description) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { const data = await fetch( - 'https://api.thedogapi.com/v1/images/search', - FetchResultTypes.JSON, + "https://api.thedogapi.com/v1/images/search", + FetchResultTypes.JSON ).catch((error) => this.container.logger.error(error)); const embed = new EmbedBuilder(); @@ -30,10 +30,10 @@ export class DogCommand extends Command { embeds: [ embed .setAuthor({ - name: 'Something went wrong! 🐶', + name: "Something went wrong! 🐶", iconURL: interaction.user.avatarURL()!, }) - .setColor('Red') + .setColor("Red") .setDescription(`Couldn't fetch a dog 🐶\nTry again later!`), ], }); @@ -46,8 +46,8 @@ export class DogCommand extends Command { iconURL: interaction.user.avatarURL()!, }) .setImage(data[0].url) - .setColor('Blue') - .setFooter({ text: 'Powered by thedogapi.com' }), + .setColor("Blue") + .setFooter({ text: "Powered by thedogapi.com" }), ], }); } diff --git a/src/commands/fun/duck.ts b/src/commands/fun/duck.ts index d8e536f..0b162be 100644 --- a/src/commands/fun/duck.ts +++ b/src/commands/fun/duck.ts @@ -1,26 +1,26 @@ -import { Command } from '@sapphire/framework'; -import { fetch, FetchResultTypes } from '@sapphire/fetch'; -import { EmbedBuilder } from 'discord.js'; -import { ApplyOptions } from '@sapphire/decorators'; -import type { APIPetInterface } from '#types/index'; +import { Command } from "@sapphire/framework"; +import { fetch, FetchResultTypes } from "@sapphire/fetch"; +import { EmbedBuilder } from "discord.js"; +import { ApplyOptions } from "@sapphire/decorators"; +import type { APIPetInterface } from "#types/index"; @ApplyOptions({ - name: 'duck', - description: 'shows a duck 🦆', + name: "duck", + description: "shows a duck 🦆", }) export class DuckCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => - builder.setName(this.name).setDescription(this.description), + builder.setName(this.name).setDescription(this.description) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { const data = await fetch( - 'https://random-d.uk/api/v2/quack', - FetchResultTypes.JSON, + "https://random-d.uk/api/v2/quack", + FetchResultTypes.JSON ).catch((error) => this.container.logger.error(error)); const embed = new EmbedBuilder(); @@ -30,10 +30,10 @@ export class DuckCommand extends Command { embeds: [ embed .setAuthor({ - name: 'Something went wrong! 🦆', + name: "Something went wrong! 🦆", iconURL: interaction.user.avatarURL()!, }) - .setColor('Red') + .setColor("Red") .setDescription(`Couldn't fetch a duck 🦆\nTry again later!`), ], }); @@ -46,7 +46,7 @@ export class DuckCommand extends Command { iconURL: interaction.user.avatarURL()!, }) .setImage(data.url) - .setColor('Blue') + .setColor("Blue") .setFooter({ text: data.message! }), ], }); diff --git a/src/commands/fun/rps.ts b/src/commands/fun/rps.ts index 7279bd0..49db2f8 100644 --- a/src/commands/fun/rps.ts +++ b/src/commands/fun/rps.ts @@ -1,10 +1,10 @@ -import { Command } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; -import { EmbedBuilder } from 'discord.js'; +import { Command } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; +import { EmbedBuilder } from "discord.js"; @ApplyOptions({ - name: 'rps', - description: 'will it be: rock, paper, or scissors? 🤔', + name: "rps", + description: "will it be: rock, paper, or scissors? 🤔", }) export class RockPaperScissorsCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { @@ -14,66 +14,66 @@ export class RockPaperScissorsCommand extends Command { .setDescription(this.description) .addStringOption((option) => option - .setName('choice') - .setDescription('your choice of rock, paper, or scissors') + .setName("choice") + .setDescription("your choice of rock, paper, or scissors") .setRequired(true) .setChoices( { - name: 'Rock', - value: 'Rock', + name: "Rock", + value: "Rock", }, { - name: 'Paper', - value: 'Paper', + name: "Paper", + value: "Paper", }, { - name: 'Scissors', - value: 'Scissors', - }, - ), - ), + name: "Scissors", + value: "Scissors", + } + ) + ) ); } public override chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { const random = Math.random(); - const choice = interaction.options.getString('choice', true); - let result: 'win' | 'lose' | 'tie' = 'tie'; - const myChoice: 'Rock' | 'Paper' | 'Scissors' = - random > 0.66 ? 'Rock' : random > 0.33 ? 'Paper' : 'Scissors'; + const choice = interaction.options.getString("choice", true); + let result: "win" | "lose" | "tie" = "tie"; + const myChoice: "Rock" | "Paper" | "Scissors" = + random > 0.66 ? "Rock" : random > 0.33 ? "Paper" : "Scissors"; - if (myChoice === choice) result = 'tie'; - if (myChoice === 'Rock' && choice === 'Paper') result = 'win'; - if (myChoice === 'Rock' && choice === 'Scissors') result = 'lose'; - if (myChoice === 'Paper' && choice === 'Scissors') result = 'win'; - if (myChoice === 'Paper' && choice === 'Rock') result = 'lose'; - if (myChoice === 'Scissors' && choice === 'Rock') result = 'win'; - if (myChoice === 'Scissors' && choice === 'Paper') result = 'lose'; + if (myChoice === choice) result = "tie"; + if (myChoice === "Rock" && choice === "Paper") result = "win"; + if (myChoice === "Rock" && choice === "Scissors") result = "lose"; + if (myChoice === "Paper" && choice === "Scissors") result = "win"; + if (myChoice === "Paper" && choice === "Rock") result = "lose"; + if (myChoice === "Scissors" && choice === "Rock") result = "win"; + if (myChoice === "Scissors" && choice === "Paper") result = "lose"; return interaction.reply({ embeds: [ new EmbedBuilder() .setAuthor({ - name: 'Rock, Paper, Scissors! 🤔', + name: "Rock, Paper, Scissors! 🤔", iconURL: interaction.user.avatarURL()!, }) .addFields([ - { name: 'You picked', value: `\`${choice}\``, inline: true }, - { name: 'I picked', value: `\`${myChoice}\``, inline: true }, + { name: "You picked", value: `\`${choice}\``, inline: true }, + { name: "I picked", value: `\`${myChoice}\``, inline: true }, { - name: 'Result', + name: "Result", value: `\`${ - result === 'win' - ? 'You won!' - : result === 'lose' - ? 'You lost!' - : 'We tied!' + result === "win" + ? "You won!" + : result === "lose" + ? "You lost!" + : "We tied!" }\``, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], }); } diff --git a/src/commands/misc/avatar.ts b/src/commands/misc/avatar.ts index c2e7e9a..dd20575 100644 --- a/src/commands/misc/avatar.ts +++ b/src/commands/misc/avatar.ts @@ -1,9 +1,9 @@ -import { Command } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; -import { EmbedBuilder, type ImageExtension, type ImageSize } from 'discord.js'; +import { Command } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; +import { EmbedBuilder, type ImageExtension, type ImageSize } from "discord.js"; @ApplyOptions({ - name: 'avatar', + name: "avatar", description: "shows a user's avatar", }) export class AvatarCommand extends Command { @@ -14,49 +14,49 @@ export class AvatarCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to show the avatar of') - .setRequired(false), + .setName("user") + .setDescription("the user to show the avatar of") + .setRequired(false) ) .addNumberOption((option) => option - .setName('size') - .setDescription('the size of the avatar') + .setName("size") + .setDescription("the size of the avatar") .setRequired(false) .setChoices( - { name: '16', value: 16 }, - { name: '32', value: 32 }, - { name: '64', value: 64 }, - { name: '128', value: 128 }, - { name: '256', value: 256 }, - { name: '512', value: 512 }, - { name: '1024', value: 1024 }, - { name: '2048', value: 2048 }, - { name: '4096', value: 4096 }, - ), + { name: "16", value: 16 }, + { name: "32", value: 32 }, + { name: "64", value: 64 }, + { name: "128", value: 128 }, + { name: "256", value: 256 }, + { name: "512", value: 512 }, + { name: "1024", value: 1024 }, + { name: "2048", value: 2048 }, + { name: "4096", value: 4096 } + ) ) .addStringOption((option) => option - .setName('format') - .setDescription('the format of the avatar') + .setName("format") + .setDescription("the format of the avatar") .setRequired(false) .setChoices( - { name: 'webp', value: 'webp' }, - { name: 'png', value: 'png' }, - { name: 'jpg', value: 'jpg' }, - { name: 'jpeg', value: 'jpeg' }, - { name: 'gif', value: 'gif' }, - ), - ), + { name: "webp", value: "webp" }, + { name: "png", value: "png" }, + { name: "jpg", value: "jpg" }, + { name: "jpeg", value: "jpeg" }, + { name: "gif", value: "gif" } + ) + ) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { - const user = interaction.options.getUser('user', false) ?? interaction.user; - const size = interaction.options.getNumber('size', false) ?? 1024; - const format = interaction.options.getString('format', false) ?? 'png'; + const user = interaction.options.getUser("user", false) ?? interaction.user; + const size = interaction.options.getNumber("size", false) ?? 1024; + const format = interaction.options.getString("format", false) ?? "png"; return interaction.reply({ embeds: [ @@ -65,12 +65,12 @@ export class AvatarCommand extends Command { name: `${user.username}'s avatar`, iconURL: user.avatarURL() || undefined, }) - .setColor('Blue') + .setColor("Blue") .setImage( user.avatarURL({ size: size as ImageSize, extension: format as ImageExtension, - }), + }) ), ], }); diff --git a/src/commands/misc/serverinfo.ts b/src/commands/misc/serverinfo.ts index ce8ab74..3a461c1 100644 --- a/src/commands/misc/serverinfo.ts +++ b/src/commands/misc/serverinfo.ts @@ -1,5 +1,5 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; import { ChannelType, EmbedBuilder, @@ -7,22 +7,22 @@ import { bold, inlineCode, time, -} from 'discord.js'; +} from "discord.js"; @ApplyOptions({ - name: 'serverinfo', - description: 'shows information about the server', + name: "serverinfo", + description: "shows information about the server", runIn: CommandOptionsRunTypeEnum.GuildAny, }) export class ServerInfoCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => - builder.setName(this.name).setDescription(this.description), + builder.setName(this.name).setDescription(this.description) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { const roles = interaction.guild.roles.cache .sort((a, b) => b.position - a.position) @@ -34,53 +34,53 @@ export class ServerInfoCommand extends Command { const owner = await interaction.guild.fetchOwner(); const premiumTier = interaction.guild.premiumTier ? `Tier ${interaction.guild.premiumTier}` - : 'None'; + : "None"; const generalContent = [ - `${bold('❯ Name:')} ${inlineCode(interaction.guild.name)}`, - `${bold('❯ ID:')} ${inlineCode(interaction.guildId)}`, - `${bold('❯ Owner:')} ${inlineCode(owner!.user.tag)} (${inlineCode( - interaction.guild.ownerId, + `${bold("❯ Name:")} ${inlineCode(interaction.guild.name)}`, + `${bold("❯ ID:")} ${inlineCode(interaction.guildId)}`, + `${bold("❯ Owner:")} ${inlineCode(owner!.user.tag)} (${inlineCode( + interaction.guild.ownerId )})`, - `${bold('❯ Boost Tier:')} ${inlineCode(premiumTier)}`, - `${bold('❯ Time Created:')} ${time( + `${bold("❯ Boost Tier:")} ${inlineCode(premiumTier)}`, + `${bold("❯ Time Created:")} ${time( Math.floor(interaction.guild.createdTimestamp) / 1000, - TimestampStyles.ShortDateTime, + TimestampStyles.ShortDateTime )}`, ]; const statisticsContent = [ - `${bold('❯ Role Count:')} ${inlineCode(`${roles.length}`)}`, - `${bold('❯ Emoji Count:')} ${inlineCode(`${emojis.size}`)}`, - `${bold('❯ Regular Emoji Count:')} ${inlineCode( - `${emojis.filter((emoji) => !emoji.animated).size}`, + `${bold("❯ Role Count:")} ${inlineCode(`${roles.length}`)}`, + `${bold("❯ Emoji Count:")} ${inlineCode(`${emojis.size}`)}`, + `${bold("❯ Regular Emoji Count:")} ${inlineCode( + `${emojis.filter((emoji) => !emoji.animated).size}` )}`, - `${bold('❯ Animated Emoji Count:')} ${inlineCode( - `${emojis.filter((emoji) => emoji.animated).size}`, + `${bold("❯ Animated Emoji Count:")} ${inlineCode( + `${emojis.filter((emoji) => emoji.animated).size}` )}`, - `${bold('❯ Member Count:')} ${inlineCode( - `${interaction.guild.memberCount}`, + `${bold("❯ Member Count:")} ${inlineCode( + `${interaction.guild.memberCount}` )}`, - `${bold('❯ Humans:')} ${inlineCode( - `${members.filter((member) => !member.user.bot).size}`, + `${bold("❯ Humans:")} ${inlineCode( + `${members.filter((member) => !member.user.bot).size}` )}`, - `${bold('❯ Bots:')} ${inlineCode( - `${members.filter((member) => member.user.bot).size}`, + `${bold("❯ Bots:")} ${inlineCode( + `${members.filter((member) => member.user.bot).size}` )}`, - `${bold('❯ Text Channels:')} ${inlineCode( + `${bold("❯ Text Channels:")} ${inlineCode( `${ channels.filter((channel) => channel.type === ChannelType.GuildText) .size - }`, + }` )}`, - `${bold('❯ Voice Channels:')} ${inlineCode( + `${bold("❯ Voice Channels:")} ${inlineCode( `${ channels.filter((channel) => channel.type === ChannelType.GuildVoice) .size - }`, + }` )}`, - `${bold('❯ Boost Count:')} ${inlineCode( - `${interaction.guild.premiumSubscriptionCount || '0'}`, + `${bold("❯ Boost Count:")} ${inlineCode( + `${interaction.guild.premiumSubscriptionCount || "0"}` )}}`, ]; @@ -89,18 +89,18 @@ export class ServerInfoCommand extends Command { new EmbedBuilder() .setAuthor({ name: `Server Info | ${interaction.guild.name}`, - iconURL: interaction.guild.iconURL() || '', + iconURL: interaction.guild.iconURL() || "", }) - .setColor('Blue') + .setColor("Blue") .addFields([ { - name: 'General', - value: generalContent.join('\n'), + name: "General", + value: generalContent.join("\n"), inline: true, }, { - name: 'Statistics', - value: statisticsContent.join('\n'), + name: "Statistics", + value: statisticsContent.join("\n"), inline: true, }, ]) diff --git a/src/commands/misc/setnick.ts b/src/commands/misc/setnick.ts index d121c6b..f49c94e 100644 --- a/src/commands/misc/setnick.ts +++ b/src/commands/misc/setnick.ts @@ -1,10 +1,10 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; -import { EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; +import { EmbedBuilder, PermissionFlagsBits } from "discord.js"; @ApplyOptions({ - name: 'setnick', - description: 'set the nickname of a user', + name: "setnick", + description: "set the nickname of a user", requiredClientPermissions: [PermissionFlagsBits.ManageNicknames], requiredUserPermissions: [PermissionFlagsBits.ManageNicknames], runIn: CommandOptionsRunTypeEnum.GuildAny, @@ -17,25 +17,25 @@ export class SetNickCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to set the nickname of') - .setRequired(true), + .setName("user") + .setDescription("the user to set the nickname of") + .setRequired(true) ) .addStringOption((option) => option - .setName('nickname') - .setDescription('the nickname to set') + .setName("nickname") + .setDescription("the nickname to set") .setRequired(true) - .setMaxLength(32), - ), + .setMaxLength(32) + ) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', true); - const nickname = interaction.options.getString('nickname', true); + const user = interaction.options.getUser("user", true); + const nickname = interaction.options.getString("nickname", true); const member = await interaction.guild.members.fetch(user.id); const oldNickname = member.nickname || member.displayName; @@ -44,17 +44,17 @@ export class SetNickCommand extends Command { embeds: [ new EmbedBuilder() .setAuthor({ - name: 'Cannot Set Nickname', - iconURL: user.avatarURL() || '', + name: "Cannot Set Nickname", + iconURL: user.avatarURL() || "", }) .addFields([ { - name: 'Reason', - value: 'Cannot set the nickname of the server owner', + name: "Reason", + value: "Cannot set the nickname of the server owner", }, ]) - .setColor('Blue'), + .setColor("Blue"), ], }); } @@ -66,22 +66,22 @@ export class SetNickCommand extends Command { new EmbedBuilder() .setAuthor({ name: `Nickname Set | ${user.tag}`, - iconURL: user.avatarURL() || '', + iconURL: user.avatarURL() || "", }) .addFields([ { - name: 'Old Nickname', + name: "Old Nickname", value: `\`${oldNickname}\``, inline: true, }, { - name: 'New Nickname', + name: "New Nickname", value: `\`${nickname}\``, inline: true, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], }); } diff --git a/src/commands/misc/whois.ts b/src/commands/misc/whois.ts index 959a2ee..043bbf3 100644 --- a/src/commands/misc/whois.ts +++ b/src/commands/misc/whois.ts @@ -1,10 +1,10 @@ -import { Command } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; -import { EmbedBuilder } from 'discord.js'; +import { Command } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; +import { EmbedBuilder } from "discord.js"; @ApplyOptions({ - name: 'whois', - description: 'shows information about a user', + name: "whois", + description: "shows information about a user", }) export class WhoisCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { @@ -14,17 +14,17 @@ export class WhoisCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to show information about') - .setRequired(false), - ), + .setName("user") + .setDescription("the user to show information about") + .setRequired(false) + ) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction, + interaction: Command.ChatInputCommandInteraction ) { - const user = interaction.options.getUser('user') ?? interaction.user; + const user = interaction.options.getUser("user") ?? interaction.user; return interaction.reply({ embeds: [ @@ -33,10 +33,10 @@ export class WhoisCommand extends Command { name: `Whois | ${user.tag}`, iconURL: user.displayAvatarURL(), }) - .setColor(user.hexAccentColor ?? 'Blue') + .setColor(user.hexAccentColor ?? "Blue") .addFields([ { - name: 'General', + name: "General", value: `**❯ Name:** \`${user.tag}\` (\`${ user.id }\`)\n**❯ Bot:** \`${ diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 466f8a0..d12e21f 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,4 +1,4 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; import { ActionRowBuilder, ButtonBuilder, @@ -6,14 +6,14 @@ import { EmbedBuilder, PermissionFlagsBits, inlineCode, -} from 'discord.js'; -import { Time } from '@sapphire/time-utilities'; -import { ApplyOptions } from '@sapphire/decorators'; -import { ModerationType } from '@prisma/client'; +} from "discord.js"; +import { Time } from "@sapphire/time-utilities"; +import { ApplyOptions } from "@sapphire/decorators"; +import { ModerationType } from "@prisma/client"; @ApplyOptions({ - name: 'ban', - description: 'ban a member 🔨', + name: "ban", + description: "ban a member 🔨", requiredUserPermissions: [PermissionFlagsBits.BanMembers], requiredClientPermissions: [PermissionFlagsBits.BanMembers], runIn: CommandOptionsRunTypeEnum.GuildAny, @@ -26,63 +26,63 @@ export class BanCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to ban') - .setRequired(true), + .setName("user") + .setDescription("the user to ban") + .setRequired(true) ) .addStringOption((option) => option - .setName('reason') - .setDescription('the reason for the ban') - .setRequired(false), + .setName("reason") + .setDescription("the reason for the ban") + .setRequired(false) ) .addIntegerOption((option) => option - .setName('days') + .setName("days") .setDescription( - 'the amount of days to ban the user for, default is a perma ban', + "the amount of days to ban the user for, default is a perma ban" ) .setRequired(false) .addChoices( { - name: '1 day', + name: "1 day", value: 1, }, { - name: '1 week', + name: "1 week", value: 7, }, { - name: '2 weeks', + name: "2 weeks", value: 14, }, { - name: '1 month', + name: "1 month", value: 28, - }, - ), + } + ) ) .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers); }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', true); + const user = interaction.options.getUser("user", true); const errorEmbed = new EmbedBuilder() .setAuthor({ name: `Error!`, iconURL: interaction.user.displayAvatarURL(), }) - .setColor('Blue'); + .setColor("Blue"); if (user.id === interaction.user.id) { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot ban yourself, you silly goose!`, + `You cannot ban yourself, you silly goose!` ), ], ephemeral: true, @@ -90,7 +90,7 @@ export class BanCommand extends Command { } const interactionMember = await interaction.guild.members.fetch( - interaction.user.id, + interaction.user.id ); const member = await interaction.guild.members.fetch(user.id); @@ -99,7 +99,7 @@ export class BanCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occured with finding the member.`, + `An error occured with finding the member.` ), ], }); @@ -115,7 +115,7 @@ export class BanCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot ban ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!`, + `You cannot ban ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!` ), ], ephemeral: true, @@ -123,7 +123,7 @@ export class BanCommand extends Command { } let reason = - interaction.options.getString('reason', false) ?? 'No reason provided'; + interaction.options.getString("reason", false) ?? "No reason provided"; reason = reason.length > 100 @@ -131,18 +131,18 @@ export class BanCommand extends Command { : reason; const cancelButton = new ButtonBuilder() - .setCustomId('cancel') - .setLabel('Cancel') + .setCustomId("cancel") + .setLabel("Cancel") .setStyle(ButtonStyle.Danger); const proceedButton = new ButtonBuilder() - .setCustomId('confirm') - .setLabel('Confirm') + .setCustomId("confirm") + .setLabel("Confirm") .setStyle(ButtonStyle.Success); const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton, + proceedButton ); const message = await interaction.reply({ @@ -153,9 +153,9 @@ export class BanCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription( - `Are you sure you want to ban ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.`, + `Are you sure you want to ban ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.` ) - .setColor('Blue'), + .setColor("Blue"), ], components: [row], fetchReply: true, @@ -167,12 +167,12 @@ export class BanCommand extends Command { time: Time.Minute, }); - if (confirmation.customId === 'confirm') { + if (confirmation.customId === "confirm") { await this.container.moderationManager.handleModeration( ModerationType.BAN, interaction, user, - reason, + reason ); await interaction.guild.bans.create(user, { @@ -188,16 +188,16 @@ export class BanCommand extends Command { }) .addFields([ { - name: 'Reason', + name: "Reason", value: inlineCode(reason), inline: true, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); - } else if (confirmation.customId === 'cancel') { + } else if (confirmation.customId === "cancel") { return interaction.editReply({ embeds: [ new EmbedBuilder() @@ -206,7 +206,7 @@ export class BanCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription(`Cancelled banning ${user}!`) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); @@ -215,7 +215,7 @@ export class BanCommand extends Command { return interaction.editReply({ embeds: [ errorEmbed.setDescription( - `You took too long to respond, so the ban has been cancelled.`, + `You took too long to respond, so the ban has been cancelled.` ), ], components: [], diff --git a/src/commands/moderation/infractions.ts b/src/commands/moderation/infractions.ts index 73d3c8d..c085569 100644 --- a/src/commands/moderation/infractions.ts +++ b/src/commands/moderation/infractions.ts @@ -1,19 +1,19 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; import { PermissionFlagsBits, TimestampStyles, bold, inlineCode, time, -} from 'discord.js'; -import { ApplyOptions } from '@sapphire/decorators'; -import { PaginatedMessage } from '@sapphire/discord.js-utilities'; -import { chunk } from '@sapphire/utilities'; -import { ModerationTypeStrings } from '#types/index'; +} from "discord.js"; +import { ApplyOptions } from "@sapphire/decorators"; +import { PaginatedMessage } from "@sapphire/discord.js-utilities"; +import { chunk } from "@sapphire/utilities"; +import { ModerationTypeStrings } from "#types/index"; @ApplyOptions({ - name: 'infractions', - description: 'show all of a members infractions, warns/bans/mutes/kicks...', + name: "infractions", + description: "show all of a members infractions, warns/bans/mutes/kicks...", requiredUserPermissions: [PermissionFlagsBits.ManageMessages], runIn: CommandOptionsRunTypeEnum.GuildAny, }) @@ -25,29 +25,29 @@ export class InfractionsCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to show infractions for') - .setRequired(false), + .setName("user") + .setDescription("the user to show infractions for") + .setRequired(false) ) .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages); }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', false) ?? interaction.user; + const user = interaction.options.getUser("user", false) ?? interaction.user; const message = new PaginatedMessage().setActions( PaginatedMessage.defaultActions.filter( (action) => - 'customId' in action && + "customId" in action && [ - '@sapphire/paginated-messages.previousPage', - '@sapphire/paginated-messages.stop', - '@sapphire/paginated-messages.nextPage', - ].includes(action.customId), - ), + "@sapphire/paginated-messages.previousPage", + "@sapphire/paginated-messages.stop", + "@sapphire/paginated-messages.nextPage", + ].includes(action.customId) + ) ); let guildInDB = await this.container.prisma.guild.findUnique({ @@ -79,7 +79,7 @@ export class InfractionsCommand extends Command { if (!infractions || !infractions.length) { return interaction.reply({ - content: 'This user has no infractions', + content: "This user has no infractions", ephemeral: true, }); } @@ -91,31 +91,31 @@ export class InfractionsCommand extends Command { name: `Infractions for ${user.tag}`, iconURL: user.displayAvatarURL(), }) - .setColor('Blue'); + .setColor("Blue"); for (const infraction of arr) { const moderator = this.container.client.users.cache.get( - infraction.moderatorId, + infraction.moderatorId )!; const id = guildInfractions.findIndex( - (inf) => inf.createdAt === infraction.createdAt, + (inf) => inf.createdAt === infraction.createdAt ) + 1; embed.addFields([ { name: `${ModerationTypeStrings[infraction.type]} - Case #${id}`, value: [ - `${bold('❯ Moderator:')} ${moderator} (${inlineCode( - moderator.id, + `${bold("❯ Moderator:")} ${moderator} (${inlineCode( + moderator.id )})`, - `${bold('❯ Reason:')} ${inlineCode(infraction.reason)}`, - `${bold('❯ Date:')} ${time( + `${bold("❯ Reason:")} ${inlineCode(infraction.reason)}`, + `${bold("❯ Date:")} ${time( Math.floor(infraction.createdAt.valueOf() / 1000), - TimestampStyles.ShortDateTime, + TimestampStyles.ShortDateTime )}`, - ].join('\n'), + ].join("\n"), }, ]); } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 7a28d41..59b876d 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,4 +1,4 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; import { ActionRowBuilder, ButtonBuilder, @@ -6,14 +6,14 @@ import { EmbedBuilder, PermissionFlagsBits, inlineCode, -} from 'discord.js'; -import { ApplyOptions } from '@sapphire/decorators'; -import { ModerationType } from '@prisma/client'; -import { Time } from '@sapphire/time-utilities'; +} from "discord.js"; +import { ApplyOptions } from "@sapphire/decorators"; +import { ModerationType } from "@prisma/client"; +import { Time } from "@sapphire/time-utilities"; @ApplyOptions({ - name: 'kick', - description: 'kick a member', + name: "kick", + description: "kick a member", requiredUserPermissions: [PermissionFlagsBits.KickMembers], requiredClientPermissions: [PermissionFlagsBits.KickMembers], runIn: CommandOptionsRunTypeEnum.GuildAny, @@ -26,37 +26,37 @@ export class KickCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to kick') - .setRequired(true), + .setName("user") + .setDescription("the user to kick") + .setRequired(true) ) .addStringOption((option) => option - .setName('reason') - .setDescription('the reason for the kick') - .setRequired(false), + .setName("reason") + .setDescription("the reason for the kick") + .setRequired(false) ) .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers); }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', true); + const user = interaction.options.getUser("user", true); const errorEmbed = new EmbedBuilder() .setAuthor({ name: `Error!`, iconURL: interaction.user.displayAvatarURL(), }) - .setColor('Blue'); + .setColor("Blue"); if (user.id === interaction.user.id) { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot kick yourself, you silly goose!`, + `You cannot kick yourself, you silly goose!` ), ], ephemeral: true, @@ -64,7 +64,7 @@ export class KickCommand extends Command { } const interactionMember = await interaction.guild.members.fetch( - interaction.user.id, + interaction.user.id ); const member = await interaction.guild.members.fetch(user.id); @@ -73,7 +73,7 @@ export class KickCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occured with finding the member.`, + `An error occured with finding the member.` ), ], }); @@ -89,7 +89,7 @@ export class KickCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot kick ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!`, + `You cannot kick ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!` ), ], ephemeral: true, @@ -97,7 +97,7 @@ export class KickCommand extends Command { } let reason = - interaction.options.getString('reason', false) ?? 'No reason provided'; + interaction.options.getString("reason", false) ?? "No reason provided"; reason = reason.length > 100 @@ -105,18 +105,18 @@ export class KickCommand extends Command { : reason; const cancelButton = new ButtonBuilder() - .setCustomId('cancel') - .setLabel('Cancel') + .setCustomId("cancel") + .setLabel("Cancel") .setStyle(ButtonStyle.Danger); const proceedButton = new ButtonBuilder() - .setCustomId('confirm') - .setLabel('Confirm') + .setCustomId("confirm") + .setLabel("Confirm") .setStyle(ButtonStyle.Success); const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton, + proceedButton ); const message = await interaction.reply({ @@ -127,9 +127,9 @@ export class KickCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription( - `Are you sure you want to kick ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.`, + `Are you sure you want to kick ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.` ) - .setColor('Blue'), + .setColor("Blue"), ], components: [row], fetchReply: true, @@ -141,12 +141,12 @@ export class KickCommand extends Command { time: Time.Minute, }); - if (confirmation.customId === 'confirm') { + if (confirmation.customId === "confirm") { await this.container.moderationManager.handleModeration( ModerationType.KICK, interaction, user, - reason, + reason ); await member.kick(reason); @@ -160,16 +160,16 @@ export class KickCommand extends Command { }) .addFields([ { - name: 'Reason', + name: "Reason", value: inlineCode(reason), inline: true, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); - } else if (confirmation.customId === 'cancel') { + } else if (confirmation.customId === "cancel") { await confirmation.update({ embeds: [ new EmbedBuilder() @@ -178,7 +178,7 @@ export class KickCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription(`Cancelled kicking ${user}`) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); @@ -187,7 +187,7 @@ export class KickCommand extends Command { await interaction.editReply({ embeds: [ errorEmbed.setDescription( - `You took too long to respond, so the kick has been cancelled.`, + `You took too long to respond, so the kick has been cancelled.` ), ], components: [], diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 6a38637..78adfd9 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,4 +1,4 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; import { ActionRowBuilder, ButtonBuilder, @@ -6,14 +6,14 @@ import { EmbedBuilder, PermissionFlagsBits, inlineCode, -} from 'discord.js'; -import { ApplyOptions } from '@sapphire/decorators'; -import { ModerationType } from '@prisma/client'; -import { Time } from '@sapphire/time-utilities'; +} from "discord.js"; +import { ApplyOptions } from "@sapphire/decorators"; +import { ModerationType } from "@prisma/client"; +import { Time } from "@sapphire/time-utilities"; @ApplyOptions({ - name: 'mute', - description: 'mute a member', + name: "mute", + description: "mute a member", requiredUserPermissions: [PermissionFlagsBits.ModerateMembers], requiredClientPermissions: [PermissionFlagsBits.ModerateMembers], runIn: CommandOptionsRunTypeEnum.GuildAny, @@ -26,102 +26,102 @@ export class MuteCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to mute') - .setRequired(true), + .setName("user") + .setDescription("the user to mute") + .setRequired(true) ) .addIntegerOption((option) => option - .setName('duration') - .setDescription('the duration of the mute') + .setName("duration") + .setDescription("the duration of the mute") .setRequired(true) .setChoices( { - name: '1 minute', + name: "1 minute", value: Time.Minute, }, { - name: '5 minutes', + name: "5 minutes", value: Time.Minute * 5, }, { - name: '10 minutes', + name: "10 minutes", value: Time.Minute * 10, }, { - name: '30 minutes', + name: "30 minutes", value: Time.Minute * 30, }, { - name: '1 hour', + name: "1 hour", value: Time.Hour, }, { - name: '6 hours', + name: "6 hours", value: Time.Hour * 6, }, { - name: '12 hours', + name: "12 hours", value: Time.Hour * 12, }, { - name: '1 day', + name: "1 day", value: Time.Day, }, { - name: '3 days', + name: "3 days", value: Time.Day * 3, }, { - name: '1 week', + name: "1 week", value: Time.Week, }, { - name: '2 weeks', + name: "2 weeks", value: Time.Week * 2, }, { - name: '1 month', + name: "1 month", value: Time.Month, }, { - name: '3 months', + name: "3 months", value: Time.Month * 3, }, { - name: '6 months', + name: "6 months", value: Time.Month * 6, - }, - ), + } + ) ) .addStringOption((option) => option - .setName('reason') - .setDescription('the reason for the mute') - .setRequired(false), + .setName("reason") + .setDescription("the reason for the mute") + .setRequired(false) ) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers); }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', true); - const duration = interaction.options.getNumber('duration', true); + const user = interaction.options.getUser("user", true); + const duration = interaction.options.getNumber("duration", true); const errorEmbed = new EmbedBuilder() .setAuthor({ name: `Error!`, iconURL: interaction.user.displayAvatarURL(), }) - .setColor('Blue'); + .setColor("Blue"); if (user.id === interaction.user.id) { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot warn yourself, you silly goose!`, + `You cannot warn yourself, you silly goose!` ), ], ephemeral: true, @@ -129,7 +129,7 @@ export class MuteCommand extends Command { } const interactionMember = await interaction.guild.members.fetch( - interaction.user.id, + interaction.user.id ); const member = await interaction.guild.members.fetch(user.id); @@ -138,7 +138,7 @@ export class MuteCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occured with finding the member.`, + `An error occured with finding the member.` ), ], }); @@ -154,7 +154,7 @@ export class MuteCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot mute ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!`, + `You cannot mute ${user} because they either have a higher or equal positioned role than you or me, or they are the owner of the server!` ), ], ephemeral: true, @@ -162,7 +162,7 @@ export class MuteCommand extends Command { } let reason = - interaction.options.getString('reason', false) ?? 'No reason provided'; + interaction.options.getString("reason", false) ?? "No reason provided"; reason = reason.length > 100 @@ -170,18 +170,18 @@ export class MuteCommand extends Command { : reason; const cancelButton = new ButtonBuilder() - .setCustomId('cancel') - .setLabel('Cancel') + .setCustomId("cancel") + .setLabel("Cancel") .setStyle(ButtonStyle.Danger); const proceedButton = new ButtonBuilder() - .setCustomId('confirm') - .setLabel('Confirm') + .setCustomId("confirm") + .setLabel("Confirm") .setStyle(ButtonStyle.Success); const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton, + proceedButton ); const message = await interaction.reply({ @@ -192,9 +192,9 @@ export class MuteCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription( - `Are you sure you want to mute ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.`, + `Are you sure you want to mute ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.` ) - .setColor('Blue'), + .setColor("Blue"), ], components: [row], fetchReply: true, @@ -206,12 +206,12 @@ export class MuteCommand extends Command { time: Time.Minute, }); - if (confirmation.customId === 'confirm') { + if (confirmation.customId === "confirm") { await this.container.moderationManager.handleModeration( ModerationType.MUTE, interaction, user, - reason, + reason ); await member.timeout(duration, reason); @@ -225,21 +225,21 @@ export class MuteCommand extends Command { }) .addFields([ { - name: 'Duration', + name: "Duration", value: inlineCode(`${duration * Time.Minute}`), inline: true, }, { - name: 'Reason', + name: "Reason", value: inlineCode(reason), inline: true, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); - } else if (confirmation.customId === 'cancel') { + } else if (confirmation.customId === "cancel") { await confirmation.update({ embeds: [ new EmbedBuilder() @@ -248,7 +248,7 @@ export class MuteCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription(`Cancelled muting ${user}`) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); @@ -257,7 +257,7 @@ export class MuteCommand extends Command { await interaction.editReply({ embeds: [ errorEmbed.setDescription( - `You took too long to respond, so the warn has been cancelled.`, + `You took too long to respond, so the warn has been cancelled.` ), ], components: [], diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 0975193..adcccee 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,4 +1,4 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; import { ActionRowBuilder, ButtonBuilder, @@ -6,14 +6,14 @@ import { EmbedBuilder, PermissionFlagsBits, inlineCode, -} from 'discord.js'; -import { ApplyOptions } from '@sapphire/decorators'; -import { ModerationType } from '@prisma/client'; -import { Time } from '@sapphire/time-utilities'; +} from "discord.js"; +import { ApplyOptions } from "@sapphire/decorators"; +import { ModerationType } from "@prisma/client"; +import { Time } from "@sapphire/time-utilities"; @ApplyOptions({ - name: 'warn', - description: 'warn a member', + name: "warn", + description: "warn a member", requiredUserPermissions: [PermissionFlagsBits.ManageGuild], runIn: CommandOptionsRunTypeEnum.GuildAny, }) @@ -25,37 +25,37 @@ export class WarnCommand extends Command { .setDescription(this.description) .addUserOption((option) => option - .setName('user') - .setDescription('the user to warn') - .setRequired(true), + .setName("user") + .setDescription("the user to warn") + .setRequired(true) ) .addStringOption((option) => option - .setName('reason') - .setDescription('the reason for the warn') - .setRequired(false), + .setName("reason") + .setDescription("the reason for the warn") + .setRequired(false) ) .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild); }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { - const user = interaction.options.getUser('user', true); + const user = interaction.options.getUser("user", true); const errorEmbed = new EmbedBuilder() .setAuthor({ name: `Error!`, iconURL: interaction.user.displayAvatarURL(), }) - .setColor('Blue'); + .setColor("Blue"); if (user.id === interaction.user.id) { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot warn yourself, you silly goose!`, + `You cannot warn yourself, you silly goose!` ), ], ephemeral: true, @@ -63,7 +63,7 @@ export class WarnCommand extends Command { } const interactionMember = await interaction.guild.members.fetch( - interaction.user.id, + interaction.user.id ); const member = await interaction.guild.members.fetch(user.id); @@ -72,7 +72,7 @@ export class WarnCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occured with finding the member.`, + `An error occured with finding the member.` ), ], }); @@ -87,7 +87,7 @@ export class WarnCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot warn ${user} because they either have a higher or equal positioned role than you, or they are the owner of the server!`, + `You cannot warn ${user} because they either have a higher or equal positioned role than you, or they are the owner of the server!` ), ], ephemeral: true, @@ -95,7 +95,7 @@ export class WarnCommand extends Command { } let reason = - interaction.options.getString('reason', false) ?? 'No reason provided'; + interaction.options.getString("reason", false) ?? "No reason provided"; reason = reason.length > 100 @@ -103,18 +103,18 @@ export class WarnCommand extends Command { : reason; const cancelButton = new ButtonBuilder() - .setCustomId('cancel') - .setLabel('Cancel') + .setCustomId("cancel") + .setLabel("Cancel") .setStyle(ButtonStyle.Danger); const proceedButton = new ButtonBuilder() - .setCustomId('confirm') - .setLabel('Confirm') + .setCustomId("confirm") + .setLabel("Confirm") .setStyle(ButtonStyle.Success); const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton, + proceedButton ); const message = await interaction.reply({ @@ -125,9 +125,9 @@ export class WarnCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription( - `Are you sure you want to warn ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.`, + `Are you sure you want to warn ${user}?\n\nThis will be cancelled in 1 minute if you don't respond.` ) - .setColor('Blue'), + .setColor("Blue"), ], components: [row], fetchReply: true, @@ -139,12 +139,12 @@ export class WarnCommand extends Command { time: Time.Minute, }); - if (confirmation.customId === 'confirm') { + if (confirmation.customId === "confirm") { await this.container.moderationManager.handleModeration( ModerationType.WARN, interaction, user, - reason, + reason ); await confirmation.update({ @@ -156,16 +156,16 @@ export class WarnCommand extends Command { }) .addFields([ { - name: 'Reason', + name: "Reason", value: inlineCode(reason), inline: true, }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); - } else if (confirmation.customId === 'cancel') { + } else if (confirmation.customId === "cancel") { await confirmation.update({ embeds: [ new EmbedBuilder() @@ -174,7 +174,7 @@ export class WarnCommand extends Command { iconURL: interaction.user.displayAvatarURL(), }) .setDescription(`Cancelled warning ${user}`) - .setColor('Blue'), + .setColor("Blue"), ], components: [], }); @@ -183,7 +183,7 @@ export class WarnCommand extends Command { await interaction.editReply({ embeds: [ errorEmbed.setDescription( - `You took too long to respond, so the warn has been cancelled.`, + `You took too long to respond, so the warn has been cancelled.` ), ], components: [], diff --git a/src/commands/settings/settings.ts b/src/commands/settings/settings.ts index 30029c7..6182c6a 100644 --- a/src/commands/settings/settings.ts +++ b/src/commands/settings/settings.ts @@ -1,5 +1,5 @@ -import { Command, CommandOptionsRunTypeEnum } from '@sapphire/framework'; -import { ApplyOptions } from '@sapphire/decorators'; +import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; +import { ApplyOptions } from "@sapphire/decorators"; import { ActionRowBuilder, ButtonBuilder, @@ -8,75 +8,75 @@ import { ChannelType, EmbedBuilder, PermissionFlagsBits, -} from 'discord.js'; -import type { Guild } from '@prisma/client'; -import { Time } from '@sapphire/time-utilities'; +} from "discord.js"; +import type { Guild } from "@prisma/client"; +import { Time } from "@sapphire/time-utilities"; @ApplyOptions({ - name: 'settings', - description: 'change the settings of the bot for the current server', - requiredUserPermissions: ['ManageGuild'], - requiredClientPermissions: ['ManageGuild'], + name: "settings", + description: "change the settings of the bot for the current server", + requiredUserPermissions: ["ManageGuild"], + requiredClientPermissions: ["ManageGuild"], runIn: CommandOptionsRunTypeEnum.GuildAny, }) export class SettingsCommand extends Command { - private guildId = ''; + private guildId = ""; public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => builder .setName(this.name) .setDescription(this.description) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<'cached'>, + interaction: Command.ChatInputCommandInteraction<"cached"> ) { this.guildId = interaction.guildId!; const guildInDB: Guild = await this.getGuild(); const loggingButton = new ButtonBuilder() - .setLabel('Logging') + .setLabel("Logging") .setStyle(ButtonStyle.Primary) - .setEmoji('📝') - .setCustomId('logging'); + .setEmoji("📝") + .setCustomId("logging"); const moderationButton = new ButtonBuilder() - .setLabel('Moderation') + .setLabel("Moderation") .setStyle(ButtonStyle.Primary) - .setEmoji('🔨') - .setCustomId('moderation'); + .setEmoji("🔨") + .setCustomId("moderation"); const starboardButton = new ButtonBuilder() - .setLabel('Starboard') + .setLabel("Starboard") .setStyle(ButtonStyle.Primary) - .setEmoji('⭐') - .setCustomId('starboard'); + .setEmoji("⭐") + .setCustomId("starboard"); const funButton = new ButtonBuilder() - .setLabel('Fun') + .setLabel("Fun") .setStyle(ButtonStyle.Primary) - .setEmoji('🎉') - .setCustomId('fun'); + .setEmoji("🎉") + .setCustomId("fun"); const mainRow = new ActionRowBuilder().addComponents( loggingButton, moderationButton, starboardButton, - funButton, + funButton ); const exitButton = new ButtonBuilder() - .setCustomId('exit') - .setLabel('Exit') - .setEmoji('⬅') + .setCustomId("exit") + .setLabel("Exit") + .setEmoji("⬅") .setStyle(ButtonStyle.Secondary); const exitRow = new ActionRowBuilder().addComponents( - exitButton, + exitButton ); const message = await interaction.reply({ @@ -86,16 +86,16 @@ export class SettingsCommand extends Command { name: `Configure ${interaction.guild!.name}`, iconURL: interaction.guild.iconURL() as string, }) - .setColor('Blue') + .setColor("Blue") .addFields([ { - name: 'Use the buttons below to configure the server.', + name: "Use the buttons below to configure the server.", value: [ - `**Logging:** ${guildInDB?.logging ? '✅' : '❌'}`, - `**Moderation:** ${guildInDB?.moderation ? '✅' : '❌'}`, - `**Starboard:** ${guildInDB?.starboard ? '✅' : '❌'}`, - `**Fun:** ${guildInDB?.fun ? '✅' : '❌'}`, - ].join('\n'), + `**Logging:** ${guildInDB?.logging ? "✅" : "❌"}`, + `**Moderation:** ${guildInDB?.moderation ? "✅" : "❌"}`, + `**Starboard:** ${guildInDB?.starboard ? "✅" : "❌"}`, + `**Fun:** ${guildInDB?.fun ? "✅" : "❌"}`, + ].join("\n"), }, ]), ], @@ -108,17 +108,17 @@ export class SettingsCommand extends Command { time: Time.Minute * 5, }); - collector.on('collect', async (componentInteraction) => { + collector.on("collect", async (componentInteraction) => { collector.resetTimer(); const goBackButton = new ButtonBuilder() - .setCustomId('goBack') - .setLabel('Home') - .setEmoji('⬅') + .setCustomId("goBack") + .setLabel("Home") + .setEmoji("⬅") .setStyle(ButtonStyle.Secondary); const goBackRow = new ActionRowBuilder().addComponents( - goBackButton, + goBackButton ); const guild: Guild = await this.getGuild(); @@ -126,12 +126,12 @@ export class SettingsCommand extends Command { const id = componentInteraction.customId; if (componentInteraction.isButton()) { - if (id === 'logging') { + if (id === "logging") { await componentInteraction.update({ embeds: [ new EmbedBuilder() .setAuthor({ - name: 'Configuring the logging system', + name: "Configuring the logging system", iconURL: interaction.guild.iconURL() as string, }) .addFields([ @@ -139,59 +139,59 @@ export class SettingsCommand extends Command { name: `Use the buttons below to edit the respective channel and settings`, value: [ `**Modlog:** ${ - guild.modlogId ? `<#${guild.modlogId}>` : 'Not set' + guild.modlogId ? `<#${guild.modlogId}>` : "Not set" }`, `**Auditlog:** ${ - guild.auditlogId ? `<#${guild.auditlogId}>` : 'Not set' + guild.auditlogId ? `<#${guild.auditlogId}>` : "Not set" }`, `**Welcome:** ${ - guild.welcomeId ? `<#${guild.welcomeId}>` : 'Not set' + guild.welcomeId ? `<#${guild.welcomeId}>` : "Not set" }`, - ].join('\n'), + ].join("\n"), }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() - .setCustomId('modlog') - .setLabel('Modlog') + .setCustomId("modlog") + .setLabel("Modlog") .setStyle(ButtonStyle.Primary), new ButtonBuilder() - .setCustomId('auditlog') - .setLabel('Auditlog') + .setCustomId("auditlog") + .setLabel("Auditlog") .setStyle(ButtonStyle.Primary), new ButtonBuilder() - .setCustomId('welcome') - .setLabel('Welcome') - .setStyle(ButtonStyle.Primary), + .setCustomId("welcome") + .setLabel("Welcome") + .setStyle(ButtonStyle.Primary) ), goBackRow, ], }); - } else if (id === 'modlog' || id === 'auditlog' || id === 'welcome') { + } else if (id === "modlog" || id === "auditlog" || id === "welcome") { const channelSelector = new ChannelSelectMenuBuilder() .addChannelTypes(ChannelType.GuildText) .setCustomId(`${id}ChannelSelect`); const disableButton = new ButtonBuilder() - .setLabel('Disable') + .setLabel("Disable") .setStyle(ButtonStyle.Danger) .setCustomId(`${id}Disable`); const channelRow = new ActionRowBuilder().addComponents( - channelSelector, + channelSelector ); const goBackAndDisableRow = new ActionRowBuilder().addComponents( goBackButton, - disableButton, + disableButton ); - const name = `${id}Id` as 'modlogId' | 'auditlogId' | 'welcomeId'; + const name = `${id}Id` as "modlogId" | "auditlogId" | "welcomeId"; const channel = guild[name]; @@ -202,44 +202,44 @@ export class SettingsCommand extends Command { name: `Configuring the ${id} channel`, iconURL: interaction.guild.iconURL() as string, }) - .setColor('Blue') + .setColor("Blue") .setDescription( `Pick a channel below to edit the ${id} channel for \`${ interaction.guild!.name - }\`${channel ? '\nDisable it by selecting `Disable`' : ''}`, + }\`${channel ? "\nDisable it by selecting `Disable`" : ""}` ), ], components: [channelRow, channel ? goBackAndDisableRow : goBackRow], }); - } else if (id === 'moderation') { + } else if (id === "moderation") { await componentInteraction.update({ embeds: [ new EmbedBuilder() .setAuthor({ - name: 'Configuring the moderation system', + name: "Configuring the moderation system", iconURL: interaction.guild.iconURL() as string, }) .addFields([ { name: `Use the buttons below to edit the respective channel and settings`, value: [ - `**Blacklist Words:** ${guild?.blacklist ? '✅' : '❌'}`, - ].join('\n'), + `**Blacklist Words:** ${guild?.blacklist ? "✅" : "❌"}`, + ].join("\n"), }, ]) - .setColor('Blue'), + .setColor("Blue"), ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() - .setCustomId('blacklistWords') - .setLabel('Blacklist Words') - .setStyle(ButtonStyle.Primary), + .setCustomId("blacklistWords") + .setLabel("Blacklist Words") + .setStyle(ButtonStyle.Primary) ), goBackRow, ], }); - } else if (id === 'goBack') { + } else if (id === "goBack") { await componentInteraction.update({ embeds: [ new EmbedBuilder() @@ -247,23 +247,23 @@ export class SettingsCommand extends Command { name: `Configure ${interaction.guild!.name}`, iconURL: interaction.guild.iconURL() ?? undefined, }) - .setColor('Blue') + .setColor("Blue") .addFields([ { - name: 'Use the buttons below to configure the server.', + name: "Use the buttons below to configure the server.", value: [ - `**Logging:** ${guildInDB?.logging ? '✅' : '❌'}`, - `**Moderation:** ${guildInDB?.moderation ? '✅' : '❌'}`, - `**Starboard:** ${guildInDB?.starboard ? '✅' : '❌'}`, - `**Fun:** ${guildInDB?.fun ? '✅' : '❌'}`, - ].join('\n'), + `**Logging:** ${guildInDB?.logging ? "✅" : "❌"}`, + `**Moderation:** ${guildInDB?.moderation ? "✅" : "❌"}`, + `**Starboard:** ${guildInDB?.starboard ? "✅" : "❌"}`, + `**Fun:** ${guildInDB?.fun ? "✅" : "❌"}`, + ].join("\n"), }, ]), ], components: [mainRow, exitRow], }); - } else if (id.endsWith('Disable')) { - const name = id.split('Disable')[0]; + } else if (id.endsWith("Disable")) { + const name = id.split("Disable")[0]; const customId = `${name}Id`; @@ -283,11 +283,11 @@ export class SettingsCommand extends Command { name: `Success`, iconURL: interaction.guild.iconURL() as string, }) - .setColor('Blue') + .setColor("Blue") .setDescription( `Successfully disabled the ${name} channel for \`${ interaction.guild!.name - }\``, + }\`` ), ], components: [goBackRow], @@ -296,9 +296,9 @@ export class SettingsCommand extends Command { } else if (componentInteraction.isChannelSelectMenu()) { const channelId = componentInteraction.values[0]; - const name = id.split('ChannelSelect')[0]; + const name = id.split("ChannelSelect")[0]; - const customId = `${name}Id` as 'modlogId' | 'auditlogId' | 'welcomeId'; + const customId = `${name}Id` as "modlogId" | "auditlogId" | "welcomeId"; if (guild[customId] === channelId) { await componentInteraction.update({ @@ -308,9 +308,9 @@ export class SettingsCommand extends Command { name: `Error while editing ${interaction.guild!.name}`, iconURL: interaction.guild.iconURL() as string, }) - .setColor('Blue') + .setColor("Blue") .setDescription( - `<#${channelId}> is already set as the ${name} channel!`, + `<#${channelId}> is already set as the ${name} channel!` ), ], components: [goBackRow], @@ -334,9 +334,9 @@ export class SettingsCommand extends Command { name: `Success`, iconURL: interaction.guild.iconURL() as string, }) - .setColor('Blue') + .setColor("Blue") .setDescription( - `Successfully set the ${name} channel to <#${channelId}>`, + `Successfully set the ${name} channel to <#${channelId}>` ), ], components: [goBackRow], @@ -344,18 +344,18 @@ export class SettingsCommand extends Command { } }); - collector.on('dispose', async () => { + collector.on("dispose", async () => { const embed = new EmbedBuilder() .setAuthor({ - name: 'Exited', + name: "Exited", iconURL: interaction.user.displayAvatarURL(), }) .setDescription( `Run the \`/settings\` command again to change the settings for \`${ interaction.guild!.name - }\``, + }\`` ) - .setColor('Blue'); + .setColor("Blue"); await interaction.editReply({ embeds: [embed] }); }); diff --git a/src/index.ts b/src/index.ts index 21757d3..9711675 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,25 +1,25 @@ -import '@sapphire/plugin-logger/register'; -import '@sapphire/plugin-api/register'; +import "@sapphire/plugin-logger/register"; +import "@sapphire/plugin-api/register"; -import { PrismaClient } from '@prisma/client'; +import { PrismaClient } from "@prisma/client"; import { ApplicationCommandRegistries, LogLevel, RegisterBehavior, SapphireClient, container, -} from '@sapphire/framework'; -import { GatewayIntentBits, OAuth2Scopes, Partials } from 'discord.js'; -import { ModerationManager } from '#classes/index'; -import { envParseNumber, envParseString, setup } from '@skyra/env-utilities'; -import { join } from 'path'; +} from "@sapphire/framework"; +import { GatewayIntentBits, OAuth2Scopes, Partials } from "discord.js"; +import { ModerationManager } from "#classes/index"; +import { envParseNumber, envParseString, setup } from "@skyra/env-utilities"; +import { join } from "path"; -process.env.NODE_ENV ??= 'development'; -setup({ path: join(__dirname, '..', `.env.${process.env.NODE_ENV}.local`) }); +process.env.NODE_ENV ??= "development"; +setup({ path: join(__dirname, "..", `.env.${process.env.NODE_ENV}.local`) }); async function start() { ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical( - RegisterBehavior.BulkOverwrite, + RegisterBehavior.BulkOverwrite ); const client = new SapphireClient({ @@ -32,20 +32,20 @@ async function start() { partials: [Partials.GuildMember, Partials.Reaction, Partials.User], logger: { level: - process.env.NODE_ENV === 'production' ? LogLevel.Info : LogLevel.Debug, + process.env.NODE_ENV === "production" ? LogLevel.Info : LogLevel.Debug, }, api: { auth: { - id: envParseString('CLIENT_ID'), - cookie: envParseString('OAUTH_COOKIE'), - secret: envParseString('CLIENT_SECRET'), + id: envParseString("CLIENT_ID"), + cookie: envParseString("OAUTH_COOKIE"), + secret: envParseString("CLIENT_SECRET"), scopes: [OAuth2Scopes.Identify, OAuth2Scopes.Guilds], - redirect: envParseString('OAUTH_REDIRECT'), + redirect: envParseString("OAUTH_REDIRECT"), }, - prefix: envParseString('API_PREFIX'), - origin: envParseString('API_ORIGIN'), + prefix: envParseString("API_PREFIX"), + origin: envParseString("API_ORIGIN"), listenOptions: { - port: envParseNumber('API_PORT', 3000), + port: envParseNumber("API_PORT", 3000), }, }, }); @@ -55,7 +55,7 @@ async function start() { const prisma = new PrismaClient(); container.prisma = prisma; await prisma.$connect().then(() => { - container.logger.info('Connected to Database successfully!'); + container.logger.info("Connected to Database successfully!"); }); const moderationManager = new ModerationManager(); diff --git a/src/lib/api/decorators.ts b/src/lib/api/decorators.ts index d4bb5aa..8734b19 100644 --- a/src/lib/api/decorators.ts +++ b/src/lib/api/decorators.ts @@ -1,16 +1,16 @@ -import { createFunctionPrecondition } from '@sapphire/decorators'; -import { RateLimitManager } from '@sapphire/ratelimits'; +import { createFunctionPrecondition } from "@sapphire/decorators"; +import { RateLimitManager } from "@sapphire/ratelimits"; import { HttpCodes, type ApiRequest, type ApiResponse, -} from '@sapphire/plugin-api'; +} from "@sapphire/plugin-api"; export function authenticated() { return createFunctionPrecondition( (request: ApiRequest) => Boolean(request.auth?.token), (_request: ApiRequest, response: ApiResponse) => - response.error(HttpCodes.Unauthorized), + response.error(HttpCodes.Unauthorized) ); } @@ -18,17 +18,17 @@ export function rateLimit(time: number, limit: number = 1) { const manager = new RateLimitManager(time, limit); return createFunctionPrecondition( (request: ApiRequest, response: ApiResponse) => { - const id = (request.headers['x-api-key'] || + const id = (request.headers["x-api-key"] || request.socket.remoteAddress) as string; const bucket = manager.acquire(id); - response.setHeader('Date', new Date().toUTCString()); - response.setHeader('X-RateLimit-Limit', time); - response.setHeader('X-RateLimit-Remaining', bucket.remaining.toString()); - response.setHeader('X-RateLimit-Reset', bucket.remainingTime.toString()); + response.setHeader("Date", new Date().toUTCString()); + response.setHeader("X-RateLimit-Limit", time); + response.setHeader("X-RateLimit-Remaining", bucket.remaining.toString()); + response.setHeader("X-RateLimit-Reset", bucket.remainingTime.toString()); if (bucket.limited) { - response.setHeader('Retry-After', bucket.remainingTime.toString()); + response.setHeader("Retry-After", bucket.remainingTime.toString()); return true; } @@ -37,6 +37,6 @@ export function rateLimit(time: number, limit: number = 1) { } catch {} return false; - }, + } ); } diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index b7a1cf1..37b909e 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -1 +1 @@ -export * from './decorators'; +export * from "./decorators"; diff --git a/src/lib/classes/ModerationManager.ts b/src/lib/classes/ModerationManager.ts index f070f3c..1ddf955 100644 --- a/src/lib/classes/ModerationManager.ts +++ b/src/lib/classes/ModerationManager.ts @@ -1,13 +1,13 @@ -import { ModerationType } from '@prisma/client'; +import { ModerationType } from "@prisma/client"; import { ChatInputCommandInteraction, User, Guild, EmbedBuilder, ChannelType, -} from 'discord.js'; -import { ModerationTypeNames } from '../types'; -import { container } from '@sapphire/framework'; +} from "discord.js"; +import { ModerationTypeNames } from "../types"; +import { container } from "@sapphire/framework"; export class ModerationManager { public async handleModeration( @@ -15,7 +15,7 @@ export class ModerationManager { interaction: ChatInputCommandInteraction, user: User, reason: string, - days?: number, + days?: number ) { const { guild } = interaction; const moderator = interaction.user; @@ -41,7 +41,7 @@ export class ModerationManager { guild!.id, moderator.id, reason, - user.id, + user.id ); await this.sendModerationMessageToUser(type, user, guild!, reason); await this.sendModerationMessageToModlog( @@ -49,7 +49,7 @@ export class ModerationManager { guild!, user, moderator, - reason, + reason ); } @@ -57,7 +57,7 @@ export class ModerationManager { type: ModerationType, user: User, guild: Guild, - reason: string, + reason: string ) { const embed = new EmbedBuilder() .setAuthor({ @@ -66,13 +66,13 @@ export class ModerationManager { }) .addFields([ { - name: 'Reason', + name: "Reason", value: `\`${ reason.length > 100 ? `${reason.substring(0, 100)}...` : reason }\``, }, ]) - .setColor('Blue') + .setColor("Blue") .setTimestamp(); return user @@ -85,7 +85,7 @@ export class ModerationManager { guildId: string, moderatorId: string, reason: string, - memberId: string, + memberId: string ) { return container.prisma.modlog.create({ data: { @@ -104,7 +104,7 @@ export class ModerationManager { guild: Guild, user: User, moderator: User, - reason: string, + reason: string ) { let guildInDB = await container.prisma.guild.findUnique({ where: { @@ -128,8 +128,8 @@ export class ModerationManager { container.logger.error( `[${guild.name} (${guild.id})] Could not fetch modlog channel ${ guildInDB!.modlogId - }`, - ), + }` + ) ); if (!modlogChannel || modlogChannel!.type !== ChannelType.GuildText) return; @@ -141,15 +141,15 @@ export class ModerationManager { }) .addFields([ { - name: 'Reason', + name: "Reason", value: `\`${reason}\``, }, { - name: 'Moderator', + name: "Moderator", value: `${moderator} (\`${moderator.id}\`)`, }, ]) - .setColor('Blue') + .setColor("Blue") .setTimestamp(); return modlogChannel.send({ embeds: [embed] }); diff --git a/src/lib/classes/Utils.ts b/src/lib/classes/Utils.ts index 5693732..ae5c7dd 100644 --- a/src/lib/classes/Utils.ts +++ b/src/lib/classes/Utils.ts @@ -1,7 +1,7 @@ -import { container } from '@sapphire/framework'; -import type { Guild, GuildTextBasedChannel } from 'discord.js'; +import { container } from "@sapphire/framework"; +import type { Guild, GuildTextBasedChannel } from "discord.js"; export async function auditlogChecks( - guild: Guild, + guild: Guild ): Promise { if (!guild) return false; @@ -19,8 +19,8 @@ export async function auditlogChecks( .fetch(guildInDB.auditlogId) .catch(() => container.logger.error( - `Invalid logging channel ID for Guild ${guild.name} (${guild.id})`, - ), + `Invalid logging channel ID for Guild ${guild.name} (${guild.id})` + ) ); if (!loggingChannel || !loggingChannel.isTextBased()) return false; diff --git a/src/lib/classes/index.ts b/src/lib/classes/index.ts index 6862591..e26c85a 100644 --- a/src/lib/classes/index.ts +++ b/src/lib/classes/index.ts @@ -1,2 +1,2 @@ -export * from './ModerationManager'; -export * from './Utils'; +export * from "./ModerationManager"; +export * from "./Utils"; diff --git a/src/lib/types/Augments.d.ts b/src/lib/types/Augments.d.ts index 552bdaf..b89ea64 100644 --- a/src/lib/types/Augments.d.ts +++ b/src/lib/types/Augments.d.ts @@ -1,16 +1,15 @@ -import type { ModerationManager, Utils } from '@lib/classes'; -import type { PrismaClient } from '@prisma/client'; -import type { NumberString } from '@skyra/env-utilities'; +import type { ModerationManager } from "#classes/index"; +import type { PrismaClient } from "@prisma/client"; +import type { NumberString } from "@skyra/env-utilities"; -declare module '@sapphire/pieces' { +declare module "@sapphire/pieces" { interface Container { prisma: PrismaClient; moderationManager: ModerationManager; - utils: Utils; } } -declare module '@skyra/env-utilities' { +declare module "@skyra/env-utilities" { interface Env { DISCORD_TOKEN: string; CLIENT_ID: string; diff --git a/src/lib/types/Util.ts b/src/lib/types/Util.ts index b2192a7..ca63536 100644 --- a/src/lib/types/Util.ts +++ b/src/lib/types/Util.ts @@ -1,5 +1,5 @@ -import { ModerationType } from '@prisma/client'; -import { ChannelType } from 'discord.js'; +import { ModerationType } from "@prisma/client"; +import { ChannelType } from "discord.js"; export type APIPetResponse = Array; @@ -9,29 +9,29 @@ export interface APIPetInterface { } export const ModerationTypeNames = { - [ModerationType.BAN]: 'Banned', - [ModerationType.KICK]: 'Kicked', - [ModerationType.MUTE]: 'Muted', - [ModerationType.WARN]: 'Warned', + [ModerationType.BAN]: "Banned", + [ModerationType.KICK]: "Kicked", + [ModerationType.MUTE]: "Muted", + [ModerationType.WARN]: "Warned", }; export const ModerationTypeStrings = { - [ModerationType.BAN]: 'Ban', - [ModerationType.KICK]: 'Kick', - [ModerationType.MUTE]: 'Mute', - [ModerationType.WARN]: 'Warn', + [ModerationType.BAN]: "Ban", + [ModerationType.KICK]: "Kick", + [ModerationType.MUTE]: "Mute", + [ModerationType.WARN]: "Warn", }; export const ChannelTypeNames = { - [ChannelType.GuildCategory]: 'Category', - [ChannelType.GuildStageVoice]: 'Stage Voice', - [ChannelType.GuildText]: 'Text', - [ChannelType.GuildVoice]: 'Voice', - [ChannelType.GuildForum]: 'Forum', - [ChannelType.GuildAnnouncement]: 'Announcement', - [ChannelType.AnnouncementThread]: 'Announcement Thread', - [ChannelType.PublicThread]: 'Public Thread', - [ChannelType.PrivateThread]: 'Private Thread', - [ChannelType.GuildDirectory]: 'Directory', - [ChannelType.GuildMedia]: 'Media', + [ChannelType.GuildCategory]: "Category", + [ChannelType.GuildStageVoice]: "Stage Voice", + [ChannelType.GuildText]: "Text", + [ChannelType.GuildVoice]: "Voice", + [ChannelType.GuildForum]: "Forum", + [ChannelType.GuildAnnouncement]: "Announcement", + [ChannelType.AnnouncementThread]: "Announcement Thread", + [ChannelType.PublicThread]: "Public Thread", + [ChannelType.PrivateThread]: "Private Thread", + [ChannelType.GuildDirectory]: "Directory", + [ChannelType.GuildMedia]: "Media", }; diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index d1260b0..7049ec3 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -1 +1 @@ -export * from './Util'; +export * from "./Util"; diff --git a/src/listeners/client/chatInputCommandDenied.ts b/src/listeners/client/chatInputCommandDenied.ts index 952f076..808d2b1 100644 --- a/src/listeners/client/chatInputCommandDenied.ts +++ b/src/listeners/client/chatInputCommandDenied.ts @@ -1,10 +1,10 @@ -import { ApplyOptions } from '@sapphire/decorators'; +import { ApplyOptions } from "@sapphire/decorators"; import { Events, Listener, type ChatInputCommandDeniedPayload, type UserError, -} from '@sapphire/framework'; +} from "@sapphire/framework"; @ApplyOptions({ event: Events.ChatInputCommandDenied, @@ -12,9 +12,9 @@ import { export class ChatInputCommandDeniedCooldownListener extends Listener { public async run( error: UserError, - { interaction }: ChatInputCommandDeniedPayload, + { interaction }: ChatInputCommandDeniedPayload ) { - if (error.identifier === 'preconditionCooldown') { + if (error.identifier === "preconditionCooldown") { if (interaction.deferred || interaction.replied) { await interaction.editReply({ content: `Woah, slow down there! Try again in \`${ diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts index d63c303..cbb8040 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -1,6 +1,6 @@ -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import type { Client } from 'discord.js'; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import type { Client } from "discord.js"; @ApplyOptions({ once: true, diff --git a/src/listeners/guild/channelCreate.ts b/src/listeners/guild/channelCreate.ts index e8fc2fb..135458e 100644 --- a/src/listeners/guild/channelCreate.ts +++ b/src/listeners/guild/channelCreate.ts @@ -1,8 +1,8 @@ -import { auditlogChecks } from '#classes/Utils'; -import { ChannelTypeNames } from '#types/Util'; -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, type GuildChannel } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ChannelTypeNames } from "#types/Util"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, type GuildChannel } from "discord.js"; @ApplyOptions({ event: Events.ChannelCreate, @@ -15,26 +15,26 @@ export class ChannelCreateListener extends Listener { const embed = new EmbedBuilder() .setAuthor({ name: `Channel Created`, - iconURL: channel.guild.iconURL() || '', + iconURL: channel.guild.iconURL() || "", }) .addFields([ { - name: 'Channel Name', + name: "Channel Name", value: channel.name, inline: true, }, { - name: 'Channel Type', + name: "Channel Type", value: `\`${ChannelTypeNames[channel.type]}\``, inline: true, }, { - name: 'Channel ID', + name: "Channel ID", value: `\`${channel.id}\``, inline: true, }, ]) - .setColor('Blue'); + .setColor("Blue"); return audit_channel.send({ embeds: [embed], diff --git a/src/listeners/guild/guildCreate.ts b/src/listeners/guild/guildCreate.ts index 3beb268..3b9f319 100644 --- a/src/listeners/guild/guildCreate.ts +++ b/src/listeners/guild/guildCreate.ts @@ -1,6 +1,6 @@ -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import type { Guild } from 'discord.js'; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import type { Guild } from "discord.js"; @ApplyOptions({ event: Events.GuildCreate, diff --git a/src/listeners/guild/guildDelete.ts b/src/listeners/guild/guildDelete.ts index 87d94a7..4b51995 100644 --- a/src/listeners/guild/guildDelete.ts +++ b/src/listeners/guild/guildDelete.ts @@ -1,6 +1,6 @@ -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import type { Guild } from 'discord.js'; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import type { Guild } from "discord.js"; @ApplyOptions({ event: Events.GuildCreate, diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index f4a3800..d746354 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -1,6 +1,6 @@ -import { ApplyOptions } from '@sapphire/decorators'; -import { Listener, Events } from '@sapphire/framework'; -import { EmbedBuilder, type GuildMember } from 'discord.js'; +import { ApplyOptions } from "@sapphire/decorators"; +import { Listener, Events } from "@sapphire/framework"; +import { EmbedBuilder, type GuildMember } from "discord.js"; @ApplyOptions({ event: Events.GuildMemberAdd, @@ -30,8 +30,8 @@ export class GuildMemberAddListener extends Listener { .fetch(guildInDB.welcomeId) .catch(() => this.container.logger.error( - `Invalid welcome channel ID for Guild ${guild.name} (${guild.id})`, - ), + `Invalid welcome channel ID for Guild ${guild.name} (${guild.id})` + ) ); if (!welcomeChannel || !welcomeChannel.isTextBased()) return; @@ -45,24 +45,24 @@ export class GuildMemberAddListener extends Listener { iconURL: member.user.displayAvatarURL(), }) .setDescription( - `Welcome to ${guild.name}, ${member.user.toString()}!`, + `Welcome to ${guild.name}, ${member.user.toString()}!` ) .addFields([ { - name: 'User Created', + name: "User Created", value: ``, }, ]) - .setColor('Blue') + .setColor("Blue") .setFooter({ text: `ID: ${member.id}` }) .setTimestamp(), ], }) .catch(() => { this.container.logger.error( - `I do not have permission to send a welcome message in channel (${welcomeChannel.id}) for Guild ${guild.name} (${guild.id})`, + `I do not have permission to send a welcome message in channel (${welcomeChannel.id}) for Guild ${guild.name} (${guild.id})` ); }); } diff --git a/src/listeners/guild/messageDelete.ts b/src/listeners/guild/messageDelete.ts index 9e79bf1..bf1b960 100644 --- a/src/listeners/guild/messageDelete.ts +++ b/src/listeners/guild/messageDelete.ts @@ -1,13 +1,14 @@ -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, type Message } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, type Message } from "discord.js"; @ApplyOptions({ event: Events.MessageDelete, }) export class MessageDeleteListener extends Listener { public async run(message: Message) { - const channel = await this.container.utils.auditlogChecks(message.guild); + const channel = await auditlogChecks(message.guild); if (!channel) return; if (message.author.bot) return; @@ -19,12 +20,12 @@ export class MessageDeleteListener extends Listener { }) .addFields([ { - name: 'Message Content', + name: "Message Content", value: message.content, inline: true, }, ]) - .setColor('Blue'); + .setColor("Blue"); return channel.send({ embeds: [embed], diff --git a/src/listeners/guild/messageUpdate.ts b/src/listeners/guild/messageUpdate.ts index df8a51e..0e79e42 100644 --- a/src/listeners/guild/messageUpdate.ts +++ b/src/listeners/guild/messageUpdate.ts @@ -1,7 +1,7 @@ -import { auditlogChecks } from '#classes/Utils'; -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, type Message } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, type Message } from "discord.js"; @ApplyOptions({ event: Events.MessageUpdate, @@ -21,17 +21,17 @@ export class MessageUpdateListener extends Listener { }) .addFields([ { - name: 'Old Message', + name: "Old Message", value: oldMessage.content, inline: true, }, { - name: 'New Message', + name: "New Message", value: newMessage.content, inline: true, }, ]) - .setColor('Blue'); + .setColor("Blue"); return channel.send({ embeds: [embed], diff --git a/src/listeners/guild/roleCreate.ts b/src/listeners/guild/roleCreate.ts index a4b16e5..8f6632c 100644 --- a/src/listeners/guild/roleCreate.ts +++ b/src/listeners/guild/roleCreate.ts @@ -1,7 +1,7 @@ -import { auditlogChecks } from '#classes/Utils'; -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, roleMention, type Role } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, roleMention, type Role } from "discord.js"; @ApplyOptions({ event: Events.GuildRoleCreate, @@ -17,23 +17,23 @@ export class RoleCreateListener extends Listener { }) .addFields([ { - name: 'Role', + name: "Role", value: `${roleMention(role.id)} (\`${role.id}\`)`, inline: true, }, { - name: 'Color', + name: "Color", value: role.hexColor, inline: true, }, { - name: 'Hoisted', - value: role.hoist ? '`Yes`' : '`No`', + name: "Hoisted", + value: role.hoist ? "`Yes`" : "`No`", inline: true, }, { - name: 'Mentionable', - value: role.mentionable ? '`Yes`' : '`No`', + name: "Mentionable", + value: role.mentionable ? "`Yes`" : "`No`", inline: true, }, ]) diff --git a/src/listeners/guild/roleDelete.ts b/src/listeners/guild/roleDelete.ts index 871044a..7b67271 100644 --- a/src/listeners/guild/roleDelete.ts +++ b/src/listeners/guild/roleDelete.ts @@ -1,7 +1,7 @@ -import { auditlogChecks } from '#classes/Utils'; -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, roleMention, type Role } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, roleMention, type Role } from "discord.js"; @ApplyOptions({ event: Events.GuildRoleDelete, @@ -17,23 +17,23 @@ export class RoleDeleteListener extends Listener { }) .addFields([ { - name: 'Role', + name: "Role", value: `${roleMention(role.id)} (\`${role.id}\`)`, inline: true, }, { - name: 'Color', + name: "Color", value: role.hexColor, inline: true, }, { - name: 'Hoisted', - value: role.hoist ? '`Yes`' : '`No`', + name: "Hoisted", + value: role.hoist ? "`Yes`" : "`No`", inline: true, }, { - name: 'Mentionable', - value: role.mentionable ? '`Yes`' : '`No`', + name: "Mentionable", + value: role.mentionable ? "`Yes`" : "`No`", inline: true, }, ]) diff --git a/src/listeners/guild/roleUpdate.ts b/src/listeners/guild/roleUpdate.ts index 2a988de..16f6894 100644 --- a/src/listeners/guild/roleUpdate.ts +++ b/src/listeners/guild/roleUpdate.ts @@ -1,7 +1,7 @@ -import { auditlogChecks } from '#classes/Utils'; -import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener } from '@sapphire/framework'; -import { EmbedBuilder, roleMention, type Role } from 'discord.js'; +import { auditlogChecks } from "#classes/Utils"; +import { ApplyOptions } from "@sapphire/decorators"; +import { Events, Listener } from "@sapphire/framework"; +import { EmbedBuilder, roleMention, type Role } from "discord.js"; @ApplyOptions({ event: Events.GuildRoleUpdate, @@ -17,29 +17,29 @@ export class RoleUpdateListener extends Listener { }) .addFields([ { - name: 'Role', + name: "Role", value: `Old Role: ${roleMention(oldRole.id)} New Role: ${roleMention( - newRole.id, + newRole.id )} (\`${newRole.id}\`)`, inline: true, }, { - name: 'Color', + name: "Color", value: `Old Color: ${oldRole.hexColor} New Color: ${newRole.hexColor}`, inline: true, }, { - name: 'Hoisted', + name: "Hoisted", value: `Hoisted Before: ${ - oldRole.hoist ? '`Yes`' : '`No`' - } Hoisted After: ${newRole.hoist ? '`Yes`' : '`No`'}`, + oldRole.hoist ? "`Yes`" : "`No`" + } Hoisted After: ${newRole.hoist ? "`Yes`" : "`No`"}`, inline: true, }, { - name: 'Mentionable', + name: "Mentionable", value: `Mentionable Before: ${ - oldRole.mentionable ? '`Yes`' : '`No`' - } Mentionable After: ${newRole.mentionable ? '`Yes`' : '`No`'}`, + oldRole.mentionable ? "`Yes`" : "`No`" + } Mentionable After: ${newRole.mentionable ? "`Yes`" : "`No`"}`, inline: true, }, ]) diff --git a/src/routes/test.ts b/src/routes/test.ts index fff0c73..b745a55 100644 --- a/src/routes/test.ts +++ b/src/routes/test.ts @@ -1,24 +1,24 @@ -import { authenticated, rateLimit } from '#api/decorators'; -import { ApplyOptions } from '@sapphire/decorators'; +import { authenticated, rateLimit } from "#api/decorators"; +import { ApplyOptions } from "@sapphire/decorators"; import { Route, methods, type ApiRequest, type ApiResponse, -} from '@sapphire/plugin-api'; +} from "@sapphire/plugin-api"; @ApplyOptions({ - route: 'test', + route: "test", }) export class TestRoute extends Route { @rateLimit(5000, 1) @authenticated() public [methods.GET](_request: ApiRequest, response: ApiResponse) { - return response.json({ message: 'Hello World!' }); + return response.json({ message: "Hello World!" }); } @authenticated() public [methods.POST](_request: ApiRequest, response: ApiResponse) { - return response.json({ message: 'Hello World!' }); + return response.json({ message: "Hello World!" }); } } diff --git a/src/tsconfig.json b/src/tsconfig.json deleted file mode 100644 index 52fc236..0000000 --- a/src/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "../dist", - "rootDir": ".", - "baseUrl": ".", - "paths": { - "#classes/*": ["lib/classes/*"], - "#api/*": ["lib/api/*"], - "#types/*": ["lib/types/*"] - }, - "composite": true - }, - "include": ["."], - "exclude": ["./tsconfig.json"] -} diff --git a/tsconfig.base.json b/tsconfig.json similarity index 51% rename from tsconfig.base.json rename to tsconfig.json index ac0f7f5..180975f 100644 --- a/tsconfig.base.json +++ b/tsconfig.json @@ -6,8 +6,13 @@ ], "compilerOptions": { "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", - "skipLibCheck": true, - "removeComments": true, - "moduleResolution": "Node16" + "outDir": "../dist", + "baseUrl": "src/", + "paths": { + "#classes/*": ["lib/classes/*"], + "#api/*": ["lib/api/*"], + "#types/*": ["lib/types/*"] + }, + "composite": true } }