diff --git a/src/commands/mod/diversityToggleOpen.ts b/src/commands/mod/diversityToggleOpen.ts index 9a82f0c..bd49301 100644 --- a/src/commands/mod/diversityToggleOpen.ts +++ b/src/commands/mod/diversityToggleOpen.ts @@ -52,16 +52,18 @@ class ToggleOpenCommand extends Command { // Checks what subcommand was run switch (subcommand) { case 'toggleopen': { - return await this.toggleOpen(interaction); + await this.toggleOpen(interaction); + return; + } + default: { + // If subcommand is invalid + await interaction.reply({ + content: 'Invalid sub command!', + ephemeral: true, + fetchReply: true, + }); } } - - // If subcommand is invalid - await interaction.reply({ - content: 'Invalid sub command!', - ephemeral: true, - fetchReply: true, - }); } // Command run diff --git a/src/commands/mod/sus.ts b/src/commands/mod/sus.ts index 00ece8f..fb2d9d7 100644 --- a/src/commands/mod/sus.ts +++ b/src/commands/mod/sus.ts @@ -59,7 +59,7 @@ async function findNotes(userId: string, active: boolean) { const prisma = new PrismaClient(); // Query to get the specific user's sus notes - const getNote = await prisma.sus.findMany({ + const note = await prisma.sus.findMany({ where: { userId, active, @@ -68,7 +68,7 @@ async function findNotes(userId: string, active: boolean) { // Close the database connection await prisma.$disconnect(); - return getNote; + return note; } // Get one note from the id @@ -77,7 +77,7 @@ async function getNote(noteId: number) { const prisma = new PrismaClient(); // Query to get the specific user's sus notes - const getNote = await prisma.sus.findUnique({ + const note = await prisma.sus.findUnique({ where: { id: noteId, }, @@ -85,7 +85,7 @@ async function getNote(noteId: number) { // Close the database connection await prisma.$disconnect(); - return getNote; + return note; } async function deactivateNote(noteId: number) { @@ -182,29 +182,34 @@ class SusCommand extends Command { // Checks what subcommand was run switch (subcommand) { case 'add': { - return await this.addNote(interaction); + await this.addNote(interaction); + return; } case 'view': { - return await this.listNote(interaction); + await this.listNote(interaction); + return; } case 'remove': { - return await this.removeNote(interaction); + await this.removeNote(interaction); + return; } case 'purge': { - return await this.removeAllNotes(interaction); + await this.removeAllNotes(interaction); + return; + } + default: { + // If subcommand is invalid + await interaction.reply({ + content: 'Invalid sub command!', + ephemeral: true, + fetchReply: true, + }); } } - - // If subcommand is invalid - await interaction.reply({ - content: 'Invalid sub command!', - ephemeral: true, - fetchReply: true, - }); } // Subcommand to add sus note - public async addNote(interaction: Command.ChatInputInteraction) { + private async addNote(interaction: Command.ChatInputInteraction) { // Get the arguments let user = interaction.options.getUser('user'); let note = interaction.options.getString('note'); @@ -261,7 +266,7 @@ class SusCommand extends Command { }); } - public async listNote(interaction: Command.ChatInputInteraction) { + private async listNote(interaction: Command.ChatInputInteraction) { // Get the arguments let user = interaction.options.getUser('user'); const { guild } = interaction; @@ -321,7 +326,7 @@ class SusCommand extends Command { }); } - public async removeNote(interaction: Command.ChatInputInteraction) { + private async removeNote(interaction: Command.ChatInputInteraction) { // Get the arguments let noteId = interaction.options.getInteger('id'); const { guild, channel } = interaction; @@ -375,7 +380,7 @@ class SusCommand extends Command { .setThumbnail(user!.avatarURL()!) // TODO avatar does not show when run .addField( `ID: ${noteId} | Moderator: ${modName} | Date: `, - note!.note, + note!.note, ); // Create buttons to delete or cancel the deletion @@ -439,7 +444,7 @@ class SusCommand extends Command { }); } - public async removeAllNotes(interaction: Command.ChatInputInteraction) { + private async removeAllNotes(interaction: Command.ChatInputInteraction) { // Get the arguments const user = interaction.options.getUser('user'); const { guild, channel } = interaction; diff --git a/src/utils/dbExistingUser.ts b/src/utils/dbExistingUser.ts index 3d0d7e2..14a5892 100644 --- a/src/utils/dbExistingUser.ts +++ b/src/utils/dbExistingUser.ts @@ -27,7 +27,7 @@ export async function userExists(user: GuildMember) { const prisma = new PrismaClient(); // Counts if the user is on the database by their snowflake - const userExists = await prisma.user.count({ + const userQuery = await prisma.user.count({ where: { id: user.id, }, @@ -37,10 +37,7 @@ export async function userExists(user: GuildMember) { await prisma.$disconnect(); // If the user is found on the database, then return true, otherwise, false. - if (userExists > 0) { - return true; - } - return false; + return userQuery > 0; } // Adds the user to the database if they were already on the server before the bot/database @@ -49,14 +46,14 @@ export async function addExistingUser(user: GuildMember) { const prisma = new PrismaClient(); // Counts if the user is on the database by their snowflake - const userExists = await prisma.user.count({ + const userQuery = await prisma.user.count({ where: { id: user.id, }, }); // If the user is already in the database - if (userExists > 0) { + if (userQuery > 0) { return; } diff --git a/src/utils/ids.ts b/src/utils/ids.ts index a142d65..6b751db 100644 --- a/src/utils/ids.ts +++ b/src/utils/ids.ts @@ -19,6 +19,7 @@ import devIDs from './devIDs'; +// eslint-disable-next-line import/no-mutable-exports let IDs = { roles: { trusted: '731563158011117590',