fix(arabot): fix eslint issues

This commit is contained in:
Anthony 2022-08-23 00:10:33 +01:00
parent 6cc8c7931a
commit 2a3c204319
4 changed files with 40 additions and 35 deletions

View File

@ -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

View File

@ -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: <t:${Math.floor(note!.time.getTime() / 1000)}>`,
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;

View File

@ -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;
}

View File

@ -19,6 +19,7 @@
import devIDs from './devIDs';
// eslint-disable-next-line import/no-mutable-exports
let IDs = {
roles: {
trusted: '731563158011117590',