diff --git a/src/commands/fun/coinflip.ts b/src/commands/fun/coinflip.ts index 085ecec..5523aa1 100644 --- a/src/commands/fun/coinflip.ts +++ b/src/commands/fun/coinflip.ts @@ -8,13 +8,13 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class CoinflipCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => builder.setName(this.name).setDescription(this.description), + registry.registerChatInputCommand((builder) => + builder.setName(this.name).setDescription(this.description), ); } public override chatInputRun( - interaction: Command.ChatInputCommandInteraction + interaction: Command.ChatInputCommandInteraction, ) { return interaction.reply({ embeds: [ diff --git a/src/commands/fun/rps.ts b/src/commands/fun/rps.ts index d10adaa..5b4d55e 100644 --- a/src/commands/fun/rps.ts +++ b/src/commands/fun/rps.ts @@ -8,36 +8,35 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class RockPaperScissorsCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => - builder - .setName(this.name) - .setDescription(this.description) - .addStringOption((option) => - option - .setName("choice") - .setDescription("your choice of rock, paper, or scissors") - .setRequired(true) - .setChoices( - { - name: "Rock", - value: "Rock", - }, - { - name: "Paper", - value: "Paper", - }, - { - name: "Scissors", - value: "Scissors", - } - ) - ), + registry.registerChatInputCommand((builder) => + builder + .setName(this.name) + .setDescription(this.description) + .addStringOption((option) => + option + .setName("choice") + .setDescription("your choice of rock, paper, or scissors") + .setRequired(true) + .setChoices( + { + name: "Rock", + value: "Rock", + }, + { + name: "Paper", + value: "Paper", + }, + { + name: "Scissors", + value: "Scissors", + }, + ), + ), ); } public override chatInputRun( - interaction: Command.ChatInputCommandInteraction + interaction: Command.ChatInputCommandInteraction, ) { const random = Math.random(); const choice = interaction.options.getString("choice", true); @@ -61,8 +60,8 @@ export class RockPaperScissorsCommand extends Command { 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", value: `\`${ diff --git a/src/commands/misc/avatar.ts b/src/commands/misc/avatar.ts index cad1b61..58d5494 100644 --- a/src/commands/misc/avatar.ts +++ b/src/commands/misc/avatar.ts @@ -8,52 +8,51 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class AvatarCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to show the avatar of") - .setRequired(false) - ) - .addNumberOption((option) => - option - .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} - ) - ) - .addStringOption((option) => - option - .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"} - ) - ), + registry.registerChatInputCommand((builder) => + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to show the avatar of") + .setRequired(false), + ) + .addNumberOption((option) => + option + .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 }, + ), + ) + .addStringOption((option) => + option + .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" }, + ), + ), ); } 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; @@ -71,7 +70,7 @@ export class AvatarCommand extends Command { 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 0b8437d..66a503b 100644 --- a/src/commands/misc/serverinfo.ts +++ b/src/commands/misc/serverinfo.ts @@ -1,5 +1,12 @@ import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; -import { bold, ChannelType, EmbedBuilder, inlineCode, time, TimestampStyles, } from "discord.js"; +import { + bold, + ChannelType, + EmbedBuilder, + inlineCode, + time, + TimestampStyles, +} from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -9,13 +16,13 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class ServerInfoCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => builder.setName(this.name).setDescription(this.description), + registry.registerChatInputCommand((builder) => + 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) @@ -70,7 +77,7 @@ export class ServerInfoCommand extends Command { inline: true, }, ]) - .setFooter({text: `ID: ${interaction.guild.id}`}), + .setFooter({ text: `ID: ${interaction.guild.id}` }), ], }); } diff --git a/src/commands/misc/whois.ts b/src/commands/misc/whois.ts index 870d4f3..5e2b632 100644 --- a/src/commands/misc/whois.ts +++ b/src/commands/misc/whois.ts @@ -8,22 +8,21 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class WhoisCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to show information about") - .setRequired(false) - ), + registry.registerChatInputCommand((builder) => + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .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; @@ -48,7 +47,7 @@ export class WhoisCommand extends Command { }, ]) - .setFooter({text: `ID: ${user.id}`}), + .setFooter({ text: `ID: ${user.id}` }), ], }); } diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index bb03dcd..5799c4e 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -8,7 +8,7 @@ import { PermissionFlagsBits, } from "discord.js"; import { ModerationType } from "@prisma/client"; -import handleInfraction from "../../utils/helpers/handleInfraction"; +import handleInfraction from "../../lib/helpers/handleInfraction"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -20,56 +20,54 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class BanCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => { - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to ban") - .setRequired(true) - ) - .addStringOption((option) => - option - .setName("reason") - .setDescription("the reason for the ban") - .setRequired(false) - ) - .addIntegerOption((option) => - option - .setName("days") - .setDescription( - "the amount of days to ban the user for, default is a permanent ban" - ) - .setRequired(false) - .addChoices( - { - name: "1 day", - value: 1, - }, - { - name: "1 week", - value: 7, - }, - { - name: "2 weeks", - value: 14, - }, - { - name: "1 month", - value: 28, - } - ) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers); - }, - ); + registry.registerChatInputCommand((builder) => { + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to ban") + .setRequired(true), + ) + .addStringOption((option) => + option + .setName("reason") + .setDescription("the reason for the ban") + .setRequired(false), + ) + .addIntegerOption((option) => + option + .setName("days") + .setDescription( + "the amount of days to ban the user for, default is a permanent ban", + ) + .setRequired(false) + .addChoices( + { + name: "1 day", + value: 1, + }, + { + name: "1 week", + value: 7, + }, + { + name: "2 weeks", + value: 14, + }, + { + 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); @@ -84,7 +82,7 @@ export class BanCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot ban yourself, you silly goose!` + `You cannot ban yourself, you silly goose!`, ), ], ephemeral: true, @@ -92,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); @@ -101,7 +99,7 @@ export class BanCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occurred with finding the member.` + `An error occurred with finding the member.`, ), ], }); @@ -117,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, @@ -129,7 +127,6 @@ export class BanCommand extends Command { if (reason.length > 100) reason = `${reason.substring(0, 100)}...`; - const cancelButton = new ButtonBuilder() .setCustomId("cancel") .setLabel("Cancel") @@ -142,7 +139,7 @@ export class BanCommand extends Command { const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton + proceedButton, ); const message = await interaction.reply({ @@ -153,7 +150,7 @@ 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"), ], @@ -210,7 +207,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 28da2e3..8cdd46d 100644 --- a/src/commands/moderation/infractions.ts +++ b/src/commands/moderation/infractions.ts @@ -1,37 +1,40 @@ import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework"; -import { bold, inlineCode, PermissionFlagsBits, time, TimestampStyles, } from "discord.js"; +import { + bold, + inlineCode, + PermissionFlagsBits, + time, + TimestampStyles, +} from "discord.js"; import { PaginatedMessage } from "@sapphire/discord.js-utilities"; import { chunk } from "@sapphire/utilities"; -import { ModerationTypeNamesPresent } from "../../utils/types"; +import { ModerationTypeNamesPresent } from "../../types/types"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ name: "infractions", - description: - "show all of a members infractions: warns/bans/mutes/kicks...", + description: "show all of a members infractions: warns/bans/mutes/kicks...", requiredUserPermissions: [PermissionFlagsBits.ManageMessages], runIn: CommandOptionsRunTypeEnum.GuildAny, }) export class InfractionsCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => { - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to show infractions for") - .setRequired(false) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers); - }, - ); + registry.registerChatInputCommand((builder) => { + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to show infractions for") + .setRequired(false), + ) + .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers); + }); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<"cached"> + interaction: Command.ChatInputCommandInteraction<"cached">, ) { const user = interaction.options.getUser("user", false) ?? interaction.user; @@ -43,8 +46,8 @@ export class InfractionsCommand extends Command { "@sapphire/paginated-messages.previousPage", "@sapphire/paginated-messages.stop", "@sapphire/paginated-messages.nextPage", - ].includes(action.customId) - ) + ].includes(action.customId), + ), ); let guildInDB = await this.container.prisma.guild.findUnique({ @@ -54,7 +57,7 @@ export class InfractionsCommand extends Command { }); if (!guildInDB) { - await this.container.prisma.guild.create({ + await this.container.prisma.guild.create({ data: { id: interaction.guildId, }, @@ -92,12 +95,12 @@ export class InfractionsCommand extends Command { 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([ @@ -105,12 +108,12 @@ export class InfractionsCommand extends Command { name: `${ModerationTypeNamesPresent[infraction.type]} - Case #${id}`, value: [ `${bold("❯ Moderator:")} ${moderator} (${inlineCode( - moderator.id + moderator.id, )})`, `${bold("❯ Reason:")} ${inlineCode(infraction.reason)}`, `${bold("❯ Date:")} ${time( Math.floor(infraction.createdAt.valueOf() / 1000), - TimestampStyles.ShortDateTime + TimestampStyles.ShortDateTime, )}`, ].join("\n"), }, diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 3997019..d4f7ad6 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -8,7 +8,7 @@ import { PermissionFlagsBits, } from "discord.js"; import { ModerationType } from "@prisma/client"; -import handleInfraction from "../../utils/helpers/handleInfraction"; +import handleInfraction from "../../lib/helpers/handleInfraction"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -20,30 +20,28 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class KickCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => { - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to kick") - .setRequired(true) - ) - .addStringOption((option) => - option - .setName("reason") - .setDescription("the reason for the kick") - .setRequired(false) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers); - }, - ); + registry.registerChatInputCommand((builder) => { + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to kick") + .setRequired(true), + ) + .addStringOption((option) => + option + .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); @@ -58,7 +56,7 @@ export class KickCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot kick yourself, you silly goose!` + `You cannot kick yourself, you silly goose!`, ), ], ephemeral: true, @@ -66,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); @@ -75,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.`, ), ], }); @@ -91,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, @@ -115,7 +113,7 @@ export class KickCommand extends Command { const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton + proceedButton, ); const message = await interaction.reply({ @@ -126,7 +124,7 @@ 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"), ], @@ -181,7 +179,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 a6ea7ce..aa8e89c 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -8,7 +8,7 @@ import { PermissionFlagsBits, } from "discord.js"; import { ModerationType } from "@prisma/client"; -import handleInfraction from "../../utils/helpers/handleInfraction"; +import handleInfraction from "../../lib/helpers/handleInfraction"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -20,86 +20,84 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class MuteCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => { - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to mute") - .setRequired(true) - ) - .addIntegerOption((option) => - option - .setName("duration") - .setDescription("the duration of the mute") - .setRequired(true) - .setChoices( - { - name: "1 minute", - value: 60000, - }, - { - name: "5 minutes", - value: 300000, - }, - { - name: "10 minutes", - value: 600000, - }, - { - name: "30 minutes", - value: 1800000, - }, - { - name: "1 hour", - value: 3600000, - }, - { - name: "6 hours", - value: 21600000, - }, - { - name: "12 hours", - value: 43200000, - }, - { - name: "1 day", - value: 86400000, - }, - { - name: "3 days", - value: 259200000, - }, - { - name: "1 week", - value: 604800000, - }, - { - name: "2 weeks", - value: 1209600000, - }, - { - name: "1 month", - value: 2629800000, - } - ) - ) - .addStringOption((option) => - option - .setName("reason") - .setDescription("the reason for the mute") - .setRequired(false) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers); - }, - ); + registry.registerChatInputCommand((builder) => { + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to mute") + .setRequired(true), + ) + .addIntegerOption((option) => + option + .setName("duration") + .setDescription("the duration of the mute") + .setRequired(true) + .setChoices( + { + name: "1 minute", + value: 60000, + }, + { + name: "5 minutes", + value: 300000, + }, + { + name: "10 minutes", + value: 600000, + }, + { + name: "30 minutes", + value: 1800000, + }, + { + name: "1 hour", + value: 3600000, + }, + { + name: "6 hours", + value: 21600000, + }, + { + name: "12 hours", + value: 43200000, + }, + { + name: "1 day", + value: 86400000, + }, + { + name: "3 days", + value: 259200000, + }, + { + name: "1 week", + value: 604800000, + }, + { + name: "2 weeks", + value: 1209600000, + }, + { + name: "1 month", + value: 2629800000, + }, + ), + ) + .addStringOption((option) => + option + .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.getInteger("duration", true); @@ -115,7 +113,7 @@ export class MuteCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot warn yourself, you silly goose!` + `You cannot warn yourself, you silly goose!`, ), ], ephemeral: true, @@ -123,7 +121,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); @@ -132,7 +130,7 @@ export class MuteCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `An error occurred with finding the member.` + `An error occurred with finding the member.`, ), ], }); @@ -148,7 +146,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, @@ -172,7 +170,7 @@ export class MuteCommand extends Command { const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton + proceedButton, ); const message = await interaction.reply({ @@ -183,7 +181,7 @@ 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"), ], @@ -245,7 +243,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 de0aa3f..3757288 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -8,7 +8,7 @@ import { PermissionFlagsBits, } from "discord.js"; import { ModerationType } from "@prisma/client"; -import handleInfraction from "../../utils/helpers/handleInfraction"; +import handleInfraction from "../../lib/helpers/handleInfraction"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -19,30 +19,28 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class WarnCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => { - builder - .setName(this.name) - .setDescription(this.description) - .addUserOption((option) => - option - .setName("user") - .setDescription("the user to warn") - .setRequired(true) - ) - .addStringOption((option) => - option - .setName("reason") - .setDescription("the reason for the warn") - .setRequired(false) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild); - }, - ); + registry.registerChatInputCommand((builder) => { + builder + .setName(this.name) + .setDescription(this.description) + .addUserOption((option) => + option + .setName("user") + .setDescription("the user to warn") + .setRequired(true), + ) + .addStringOption((option) => + option + .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); @@ -57,7 +55,7 @@ export class WarnCommand extends Command { return interaction.reply({ embeds: [ errorEmbed.setDescription( - `You cannot warn yourself, you silly goose!` + `You cannot warn yourself, you silly goose!`, ), ], ephemeral: true, @@ -65,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); @@ -74,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.`, ), ], }); @@ -89,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, @@ -113,7 +111,7 @@ export class WarnCommand extends Command { const row = new ActionRowBuilder().addComponents( cancelButton, - proceedButton + proceedButton, ); const message = await interaction.reply({ @@ -124,7 +122,7 @@ 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"), ], @@ -177,7 +175,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 32b621f..1acb4f0 100644 --- a/src/commands/settings/settings.ts +++ b/src/commands/settings/settings.ts @@ -10,7 +10,7 @@ import { MessageComponentInteraction, PermissionFlagsBits, } from "discord.js"; -import getGuild from "../../utils/helpers/getGuild"; +import getGuild from "../../lib/helpers/getGuild"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -21,17 +21,16 @@ import { ApplyOptions } from "@sapphire/decorators"; }) export class SettingsCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand( - (builder) => - builder - .setName(this.name) - .setDescription(this.description) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), + registry.registerChatInputCommand((builder) => + builder + .setName(this.name) + .setDescription(this.description) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), ); } public override async chatInputRun( - interaction: Command.ChatInputCommandInteraction<"cached"> + interaction: Command.ChatInputCommandInteraction<"cached">, ) { const guildInDB = await getGuild(interaction.guildId); @@ -56,7 +55,7 @@ export class SettingsCommand extends Command { const mainRow = new ActionRowBuilder().addComponents( loggingButton, starboardButton, - funButton + funButton, ); const exitButton = new ButtonBuilder() @@ -66,10 +65,10 @@ export class SettingsCommand extends Command { .setStyle(ButtonStyle.Secondary); const exitRow = new ActionRowBuilder().addComponents( - exitButton + exitButton, ); - const {logging, fun, starboard} = guildInDB; + const { logging, fun, starboard } = guildInDB; const message = await interaction.reply({ embeds: [ @@ -104,7 +103,7 @@ export class SettingsCommand extends Command { async (componentInteraction: MessageComponentInteraction<"cached">) => { collector.resetTimer(); - const {logging, fun, starboard} = await getGuild(interaction.guildId); + const { logging, fun, starboard } = await getGuild(interaction.guildId); const goBackButton = new ButtonBuilder() .setCustomId("goBack") @@ -113,7 +112,7 @@ export class SettingsCommand extends Command { .setStyle(ButtonStyle.Secondary); const goBackRow = new ActionRowBuilder().addComponents( - goBackButton + goBackButton, ); const id = componentInteraction.customId; @@ -154,7 +153,7 @@ export class SettingsCommand extends Command { }); } - const {starboard} = await getGuild(interaction.guildId); + const { starboard } = await getGuild(interaction.guildId); const leftButton = new ButtonBuilder() .setEmoji("⬅") @@ -184,7 +183,7 @@ export class SettingsCommand extends Command { components: [ new ActionRowBuilder().addComponents( leftButton, - rightButton + rightButton, ), goBackRow, ], @@ -204,7 +203,7 @@ export class SettingsCommand extends Command { const goBackAndDisableRow = new ActionRowBuilder().addComponents( goBackButton, - disableButton + disableButton, ); const channel = starboard!.channelId; @@ -220,12 +219,12 @@ export class SettingsCommand extends Command { .setDescription( `Pick a channel below to set as the starboard channel for \`${ interaction.guild!.name - }\`${channel ? "\nDisable it by selecting `Disable`" : ""}` + }\`${channel ? "\nDisable it by selecting `Disable`" : ""}`, ), ], components: [ new ActionRowBuilder().addComponents( - channelSelector + channelSelector, ), channel ? goBackAndDisableRow : goBackRow, ], @@ -233,17 +232,17 @@ export class SettingsCommand extends Command { } if (id === "logging" || id === "starboard" || id === "fun") { - const {logging, starboard} = await getGuild(interaction.guildId); + const { logging, starboard } = await getGuild(interaction.guildId); const toggleButton = new ButtonBuilder() .setCustomId( - `${id}${guildInDB[id]!.enabled ? "Disable" : "Enable"}` + `${id}${guildInDB[id]!.enabled ? "Disable" : "Enable"}`, ) .setLabel(guildInDB[id]!.enabled ? "Disable" : "Enable") .setStyle( guildInDB[id]!.enabled ? ButtonStyle.Danger - : ButtonStyle.Success + : ButtonStyle.Success, ); if (id === "logging") { @@ -292,7 +291,7 @@ export class SettingsCommand extends Command { .setCustomId("welcome") .setLabel("Welcome") .setStyle(ButtonStyle.Primary), - toggleButton + toggleButton, ), goBackRow, ], @@ -321,11 +320,11 @@ export class SettingsCommand extends Command { .addFields([ { name: `Use the buttons below to edit the settings for ${bold( - `${interaction.guild.name}'s` + `${interaction.guild.name}'s`, )} starboard!`, value: [ `**Stars Required:** ${bold( - starboard?.starsRequired?.toString()! + starboard?.starsRequired?.toString()!, )} ${ starboard?.starsRequired === 5 ? "(Default)" : "" }`, @@ -343,7 +342,7 @@ export class SettingsCommand extends Command { new ActionRowBuilder().addComponents( starsButton, channelSelectButton, - toggleButton + toggleButton, ), goBackRow, ], @@ -363,13 +362,13 @@ export class SettingsCommand extends Command { const channelRow = new ActionRowBuilder().addComponents( - channelSelector + channelSelector, ); const goBackAndDisableRow = new ActionRowBuilder().addComponents( goBackButton, - disableButton + disableButton, ); const name = `${id}Id` as "modlogId" | "auditlogId" | "welcomeId"; @@ -387,7 +386,7 @@ export class SettingsCommand extends Command { .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: [ @@ -448,7 +447,7 @@ export class SettingsCommand extends Command { .setDescription( `Successfully ${bold("enabled")} the ${name} system for \`${ interaction.guild!.name - }\`` + }\``, ), ], components: [goBackRow], @@ -516,7 +515,7 @@ export class SettingsCommand extends Command { name.endsWith("Id") ? name.split("Id")[0] : name } ${name.endsWith("Id") ? "channel" : "system"} for \`${ interaction.guild!.name - }\`` + }\``, ), ], components: [goBackRow], @@ -542,7 +541,7 @@ export class SettingsCommand extends Command { }) .setColor("Blue") .setDescription( - `<#${channelId}> is already set as the starboard channel!` + `<#${channelId}> is already set as the starboard channel!`, ), ], components: [goBackRow], @@ -572,7 +571,7 @@ export class SettingsCommand extends Command { }) .setColor("Blue") .setDescription( - `Successfully set the starboard channel to <#${channelId}>` + `Successfully set the starboard channel to <#${channelId}>`, ), ], components: [goBackRow], @@ -597,7 +596,7 @@ export class SettingsCommand extends Command { }) .setColor("Blue") .setDescription( - `<#${channelId}> is already set as the ${name} channel!` + `<#${channelId}> is already set as the ${name} channel!`, ), ], components: [goBackRow], @@ -627,13 +626,13 @@ export class SettingsCommand extends Command { }) .setColor("Blue") .setDescription( - `Successfully set the ${name} channel to <#${channelId}>` + `Successfully set the ${name} channel to <#${channelId}>`, ), ], components: [goBackRow], }); } - } + }, ); collector.on("dispose", async (componentInteraction) => { @@ -645,11 +644,11 @@ export class SettingsCommand extends Command { .setDescription( `Run the \`/settings\` command again to change the settings for \`${ interaction.guild!.name - }\`` + }\``, ) .setColor("Blue"); - await componentInteraction.update({embeds: [embed], components: []}); + await componentInteraction.update({ embeds: [embed], components: [] }); }); } } diff --git a/src/index.ts b/src/index.ts index 579be11..3122783 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,18 @@ -import { config } from "dotenv"; +import "@sapphire/plugin-logger/register"; +import "@sapphire/plugin-utilities-store/register"; +import "dotenv/config"; import { PrismaClient } from "@prisma/client"; +import { Time } from "@sapphire/time-utilities"; import { + ApplicationCommandRegistries, BucketScope, container, + LogLevel, + RegisterBehavior, SapphireClient, } from "@sapphire/framework"; import { GatewayIntentBits, Partials } from "discord.js"; -config(); - const client = new SapphireClient({ intents: [ GatewayIntentBits.Guilds, @@ -25,10 +29,13 @@ const client = new SapphireClient({ Partials.Reaction, ], defaultCooldown: { - delay: 3000, // 3 seconds + delay: Time.Second * 3, limit: 2, scope: BucketScope.User, }, + logger: { + level: LogLevel.Debug, + }, }); client.login(process.env.TOKEN).catch((error) => { @@ -38,6 +45,10 @@ client.login(process.env.TOKEN).catch((error) => { const prisma = new PrismaClient(); container.prisma = prisma; +ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical( + RegisterBehavior.BulkOverwrite, +); + prisma .$connect() .then(() => { @@ -45,4 +56,4 @@ prisma }) .catch((error) => { container.logger.error(error); - }); \ No newline at end of file + }); diff --git a/src/utils/helpers/getGuild.ts b/src/lib/helpers/getGuild.ts similarity index 80% rename from src/utils/helpers/getGuild.ts rename to src/lib/helpers/getGuild.ts index 6c12ab0..d631a3f 100644 --- a/src/utils/helpers/getGuild.ts +++ b/src/lib/helpers/getGuild.ts @@ -2,7 +2,7 @@ import { container } from "@sapphire/framework"; export default async function getGuild(guildId: string) { let guild = await container.prisma.guild.findUnique({ - where: {id: guildId}, + where: { id: guildId }, include: { logging: true, starboard: true, @@ -15,9 +15,9 @@ export default async function getGuild(guildId: string) { guild = await container.prisma.guild.create({ data: { id: guildId, - starboard: {create: {}}, - logging: {create: {}}, - fun: {create: {}}, + starboard: { create: {} }, + logging: { create: {} }, + fun: { create: {} }, }, include: { logging: true, diff --git a/src/utils/helpers/handleInfraction.ts b/src/lib/helpers/handleInfraction.ts similarity index 89% rename from src/utils/helpers/handleInfraction.ts rename to src/lib/helpers/handleInfraction.ts index f463a2c..2749a85 100644 --- a/src/utils/helpers/handleInfraction.ts +++ b/src/lib/helpers/handleInfraction.ts @@ -2,16 +2,16 @@ import { ModerationType } from "@prisma/client"; import { container } from "@sapphire/framework"; import { ChatInputCommandInteraction, EmbedBuilder, User } from "discord.js"; import logChecks from "./logChecks"; -import { LoggingTypes, ModerationTypeNamesPast } from "../types"; +import { LoggingTypes, ModerationTypeNamesPast } from "../../types/types"; export default async function handleInfraction( type: ModerationType, interaction: ChatInputCommandInteraction<"cached">, user: User, reason: string, - days?: number + days?: number, ) { - const {guild} = interaction; + const { guild } = interaction; const moderator = interaction.user; if (days && type === ModerationType.BAN) { @@ -57,8 +57,7 @@ export default async function handleInfraction( .setColor("Blue") .setTimestamp(); - await user.send({embeds: [embed]}).catch(() => { - }); + await user.send({ embeds: [embed] }).catch(() => {}); // Send modlog message const modlogChannel = await logChecks(guild, LoggingTypes.MODLOG); @@ -83,5 +82,5 @@ export default async function handleInfraction( .setColor("Blue") .setTimestamp(); - return modlogChannel.send({embeds: [modlogEmbed]}); + return modlogChannel.send({ embeds: [modlogEmbed] }); } diff --git a/src/utils/helpers/logChecks.ts b/src/lib/helpers/logChecks.ts similarity index 88% rename from src/utils/helpers/logChecks.ts rename to src/lib/helpers/logChecks.ts index 07a6cf2..a7c7599 100644 --- a/src/utils/helpers/logChecks.ts +++ b/src/lib/helpers/logChecks.ts @@ -1,11 +1,11 @@ import { container } from "@sapphire/framework"; import { Guild, GuildTextBasedChannel } from "discord.js"; import getGuild from "./getGuild"; -import { LoggingTypes } from "../types"; +import { LoggingTypes } from "../../types/types"; export default async function logChecks( guild: Guild, - type: LoggingTypes + type: LoggingTypes, ): Promise { const guildInDB = await getGuild(guild.id); @@ -16,8 +16,8 @@ export default async function logChecks( .fetch(guildInDB.logging[`${type}Id`]!) .catch(() => container.logger.error( - `Invalid ${type} channel ID for Guild ${guild.name} (${guild.id})` - ) + `Invalid ${type} channel ID for Guild ${guild.name} (${guild.id})`, + ), ); if (!loggingChannel || !loggingChannel.isTextBased()) return null; diff --git a/src/listeners/client/chatInputCommandDenied.ts b/src/listeners/client/chatInputCommandDenied.ts index d9f797d..89e6562 100644 --- a/src/listeners/client/chatInputCommandDenied.ts +++ b/src/listeners/client/chatInputCommandDenied.ts @@ -1,4 +1,9 @@ -import { type ChatInputCommandDeniedPayload, Events, Listener, type UserError, } from "@sapphire/framework"; +import { + type ChatInputCommandDeniedPayload, + Events, + Listener, + type UserError, +} from "@sapphire/framework"; import { ChatInputCommandInteraction } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; @@ -8,7 +13,7 @@ import { ApplyOptions } from "@sapphire/decorators"; export class ChatInputCommandDeniedListener extends Listener { public async run( error: UserError, - {interaction}: ChatInputCommandDeniedPayload + { interaction }: ChatInputCommandDeniedPayload, ) { if (error.identifier === "preconditionCooldown") { if (interaction.deferred || interaction.replied) { @@ -22,7 +27,7 @@ export class ChatInputCommandDeniedListener extends Listener { private cooldownReply( error: UserError, interaction: ChatInputCommandInteraction, - response: "reply" | "edit" + response: "reply" | "edit", ) { const content = `Woah, slow down there! Try again in \`${ // @ts-expect-error If statement checks if error is a cooldown error, so this is safe @@ -30,7 +35,7 @@ export class ChatInputCommandDeniedListener extends Listener { } seconds\``; response === "reply" - ? interaction.reply({content, ephemeral: true}) - : interaction.editReply({content}); + ? interaction.reply({ content, ephemeral: true }) + : interaction.editReply({ content }); } } diff --git a/src/listeners/client/chatInputCommandSuccess.ts b/src/listeners/client/chatInputCommandSuccess.ts index a41ba78..be300bd 100644 --- a/src/listeners/client/chatInputCommandSuccess.ts +++ b/src/listeners/client/chatInputCommandSuccess.ts @@ -1,13 +1,17 @@ -import { type ChatInputCommandSuccessPayload, Events, Listener, } from "@sapphire/framework"; +import { + type ChatInputCommandSuccessPayload, + Events, + Listener, +} from "@sapphire/framework"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ event: Events.ChatInputCommandSuccess, }) export class ChatInputCommandSuccessListener extends Listener { - public async run({command, interaction}: ChatInputCommandSuccessPayload) { + public async run({ command, interaction }: ChatInputCommandSuccessPayload) { this.container.logger.info( - `The /${command.name} command was ran by ${interaction.user.tag} successfully.` + `The /${command.name} command was ran by ${interaction.user.tag} successfully.`, ); } } diff --git a/src/listeners/guild/channelCreate.ts b/src/listeners/guild/channelCreate.ts index 9d58967..fbeae27 100644 --- a/src/listeners/guild/channelCreate.ts +++ b/src/listeners/guild/channelCreate.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type GuildChannel } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { ChannelTypeNames, LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { ChannelTypeNames, LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.ChannelCreate, @@ -11,7 +11,7 @@ export class ChannelCreateListener extends Listener { public async run(channel: GuildChannel) { const auditlogChannel = await logChecks( channel.guild, - LoggingTypes.AUDITLOG + LoggingTypes.AUDITLOG, ); if (!auditlogChannel) return; diff --git a/src/listeners/guild/channelDelete.ts b/src/listeners/guild/channelDelete.ts index 76d00c1..9839ccb 100644 --- a/src/listeners/guild/channelDelete.ts +++ b/src/listeners/guild/channelDelete.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { channelMention, EmbedBuilder, type GuildChannel } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { ChannelTypeNames, LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { ChannelTypeNames, LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.ChannelDelete, @@ -11,7 +11,7 @@ export class ChannelDeleteListener extends Listener { public async run(channel: GuildChannel) { const auditlogChannel = await logChecks( channel.guild, - LoggingTypes.AUDITLOG + LoggingTypes.AUDITLOG, ); if (!auditlogChannel) return; diff --git a/src/listeners/guild/channelUpdate.ts b/src/listeners/guild/channelUpdate.ts index ef049ca..542bcce 100644 --- a/src/listeners/guild/channelUpdate.ts +++ b/src/listeners/guild/channelUpdate.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { channelMention, EmbedBuilder, type GuildChannel } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { ChannelTypeNames, LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { ChannelTypeNames, LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.ChannelUpdate, @@ -11,7 +11,7 @@ export class ChannelUpdateListener extends Listener { public async run(channel: GuildChannel) { const auditlogChannel = await logChecks( channel.guild, - LoggingTypes.AUDITLOG + LoggingTypes.AUDITLOG, ); if (!auditlogChannel) return; diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index 8c66e98..69ff7da 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type GuildMember } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.GuildMemberAdd, @@ -12,7 +12,7 @@ export class GuildMemberAddListener extends Listener { const welcomeChannel = await logChecks(member.guild, LoggingTypes.WELCOME); if (!welcomeChannel) return; - const {guild} = member; + const { guild } = member; return welcomeChannel .send({ @@ -23,7 +23,7 @@ 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([ { @@ -34,13 +34,13 @@ export class GuildMemberAddListener extends Listener { }, ]) .setColor("Blue") - .setFooter({text: `ID: ${member.id}`}) + .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/guildMemberRemove.ts b/src/listeners/guild/guildMemberRemove.ts index 8b256c9..9ca6efb 100644 --- a/src/listeners/guild/guildMemberRemove.ts +++ b/src/listeners/guild/guildMemberRemove.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type GuildMember } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.GuildMemberRemove, @@ -12,7 +12,7 @@ export class GuildMemberRemoveListener extends Listener { const welcomeChannel = await logChecks(member.guild, LoggingTypes.WELCOME); if (!welcomeChannel) return; - const {guild} = member; + const { guild } = member; return welcomeChannel .send({ @@ -32,13 +32,13 @@ export class GuildMemberRemoveListener extends Listener { }, ]) .setColor("Red") - .setFooter({text: `ID: ${member.id}`}) + .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 120c3b9..fa4c3e6 100644 --- a/src/listeners/guild/messageDelete.ts +++ b/src/listeners/guild/messageDelete.ts @@ -1,8 +1,8 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type Message } from "discord.js"; import { ApplyOptions } from "@sapphire/decorators"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; @ApplyOptions({ event: Events.MessageDelete, diff --git a/src/listeners/guild/messageReactionAdd.ts b/src/listeners/guild/messageReactionAdd.ts index de8ddba..cfbab70 100644 --- a/src/listeners/guild/messageReactionAdd.ts +++ b/src/listeners/guild/messageReactionAdd.ts @@ -1,63 +1,17 @@ import { Events, Listener } from "@sapphire/framework"; import { ApplyOptions } from "@sapphire/decorators"; -import { EmbedBuilder, MessageReaction, User } from "discord.js"; +import { MessageReaction, User } from "discord.js"; @ApplyOptions({ event: Events.MessageReactionAdd, }) export class MessageReactionAddListener extends Listener { public async run(messageReaction: MessageReaction, user: User) { - if (!messageReaction.message.guild || user.bot) return; + if (messageReaction.partial) await messageReaction.fetch(); + if (user.partial) await user.fetch(); - if (messageReaction.emoji.name === "⭐") { - const starboard = await this.container.prisma.starboard.findUnique({ - where: { - guildId: messageReaction.message.guild.id, - }, - }); + if (user.bot || !messageReaction.message.guild) return; - if (!starboard || !starboard.enabled || !starboard.channelId) return; - - const starboardChannel = await messageReaction.message.guild.channels.fetch(starboard.channelId); - - if (!starboardChannel || !starboardChannel.isSendable()) return; - - if (messageReaction.count >= starboard.starsRequired && !starboard.starredMessages.includes((messageReaction.message.id))) { - await starboardChannel.send({ - embeds: [ - new EmbedBuilder().setDescription(messageReaction.message.content).setColor("Gold").setFooter({text: `⭐️ ${messageReaction.count} - ${messageReaction.message.id}`}) - ] - }); - - await this.container.prisma.starboard.update({ - where: { - guildId: messageReaction.message.guild.id, - }, - data: { - starredMessages: { - push: messageReaction.message.id, - }, - }, - }); - } else if (messageReaction.count < starboard.starsRequired && starboard.starredMessages.includes(messageReaction.message.id)) { - await starboardChannel.messages.fetch(); - const starredMessage = starboardChannel.messages.cache.find((m) => m.embeds[0]?.footer?.text?.endsWith(messageReaction.message.id) && m.author.id === this.container.client.user!.id); - - if (!starredMessage || !starredMessage.deletable) return; - - await starredMessage.delete(); - - await this.container.prisma.starboard.update({ - where: { - guildId: messageReaction.message.guild.id, - }, - data: { - starredMessages: { - set: starboard.starredMessages.filter((id) => id !== messageReaction.message.id), - }, - }, - }); - } - } + this.container.utilities; } -} \ No newline at end of file +} diff --git a/src/listeners/guild/messageUpdate.ts b/src/listeners/guild/messageUpdate.ts index 422d248..33ee4c2 100644 --- a/src/listeners/guild/messageUpdate.ts +++ b/src/listeners/guild/messageUpdate.ts @@ -1,7 +1,7 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type Message } from "discord.js"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ diff --git a/src/listeners/guild/roleCreate.ts b/src/listeners/guild/roleCreate.ts index 79af220..b9ea34a 100644 --- a/src/listeners/guild/roleCreate.ts +++ b/src/listeners/guild/roleCreate.ts @@ -1,7 +1,7 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type Role, roleMention } from "discord.js"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ diff --git a/src/listeners/guild/roleDelete.ts b/src/listeners/guild/roleDelete.ts index ab61e9f..546c88b 100644 --- a/src/listeners/guild/roleDelete.ts +++ b/src/listeners/guild/roleDelete.ts @@ -1,7 +1,7 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type Role, roleMention } from "discord.js"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ diff --git a/src/listeners/guild/roleUpdate.ts b/src/listeners/guild/roleUpdate.ts index ae27e15..764378b 100644 --- a/src/listeners/guild/roleUpdate.ts +++ b/src/listeners/guild/roleUpdate.ts @@ -1,7 +1,7 @@ import { Events, Listener } from "@sapphire/framework"; import { EmbedBuilder, type Role, roleMention } from "discord.js"; -import { LoggingTypes } from "../../utils/types"; -import logChecks from "../../utils/helpers/logChecks"; +import { LoggingTypes } from "../../types/types"; +import logChecks from "../../lib/helpers/logChecks"; import { ApplyOptions } from "@sapphire/decorators"; @ApplyOptions({ @@ -20,7 +20,7 @@ export class RoleUpdateListener extends Listener { { name: "Role", value: `Old Role: ${roleMention(oldRole.id)} New Role: ${roleMention( - newRole.id + newRole.id, )} (\`${newRole.id}\`)`, inline: true, }, @@ -29,8 +29,7 @@ export class RoleUpdateListener extends Listener { const colorChanged = newRole.hexColor !== oldRole.hexColor; const hoistedChanged = newRole.hoist !== oldRole.hoist; - const mentionableChanged = - newRole.mentionable !== oldRole.mentionable; + const mentionableChanged = newRole.mentionable !== oldRole.mentionable; if (colorChanged) { embed.addFields([ diff --git a/src/utils/types.ts b/src/types/types.ts similarity index 86% rename from src/utils/types.ts rename to src/types/types.ts index f49c721..b70c2ce 100644 --- a/src/utils/types.ts +++ b/src/types/types.ts @@ -1,4 +1,4 @@ -import { ModerationType, PrismaClient } from "@prisma/client"; +import { ModerationType } from "@prisma/client"; import { ChannelType } from "discord.js"; export const ModerationTypeNamesPast = { @@ -34,9 +34,3 @@ export enum LoggingTypes { WELCOME = "welcome", MODLOG = "modlog", } - -declare module "@sapphire/pieces" { - interface Container { - prisma: PrismaClient; - } -} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index e9041fd..1eb252f 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,4 +1,6 @@ { "extends": "./tsconfig.json", - "include": ["src"] + "include": [ + "src" + ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index dbbc5e2..a154b77 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,8 @@ { - "extends": ["@sapphire/ts-config", "@sapphire/ts-config/decorators"], + "extends": [ + "@sapphire/ts-config", + "@sapphire/ts-config/decorators" + ], "compilerOptions": { "outDir": "dist" }