mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 08:24:16 +02:00
fix(arabot): fix eslint issues
This commit is contained in:
parent
6cc8c7931a
commit
2a3c204319
@ -52,10 +52,10 @@ class ToggleOpenCommand extends Command {
|
|||||||
// Checks what subcommand was run
|
// Checks what subcommand was run
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'toggleopen': {
|
case 'toggleopen': {
|
||||||
return await this.toggleOpen(interaction);
|
await this.toggleOpen(interaction);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
default: {
|
||||||
|
|
||||||
// If subcommand is invalid
|
// If subcommand is invalid
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'Invalid sub command!',
|
content: 'Invalid sub command!',
|
||||||
@ -63,6 +63,8 @@ class ToggleOpenCommand extends Command {
|
|||||||
fetchReply: true,
|
fetchReply: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Command run
|
// Command run
|
||||||
public async toggleOpen(interaction: Command.ChatInputInteraction) {
|
public async toggleOpen(interaction: Command.ChatInputInteraction) {
|
||||||
|
@ -59,7 +59,7 @@ async function findNotes(userId: string, active: boolean) {
|
|||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
// Query to get the specific user's sus notes
|
// Query to get the specific user's sus notes
|
||||||
const getNote = await prisma.sus.findMany({
|
const note = await prisma.sus.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId,
|
userId,
|
||||||
active,
|
active,
|
||||||
@ -68,7 +68,7 @@ async function findNotes(userId: string, active: boolean) {
|
|||||||
|
|
||||||
// Close the database connection
|
// Close the database connection
|
||||||
await prisma.$disconnect();
|
await prisma.$disconnect();
|
||||||
return getNote;
|
return note;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get one note from the id
|
// Get one note from the id
|
||||||
@ -77,7 +77,7 @@ async function getNote(noteId: number) {
|
|||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
// Query to get the specific user's sus notes
|
// Query to get the specific user's sus notes
|
||||||
const getNote = await prisma.sus.findUnique({
|
const note = await prisma.sus.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: noteId,
|
id: noteId,
|
||||||
},
|
},
|
||||||
@ -85,7 +85,7 @@ async function getNote(noteId: number) {
|
|||||||
|
|
||||||
// Close the database connection
|
// Close the database connection
|
||||||
await prisma.$disconnect();
|
await prisma.$disconnect();
|
||||||
return getNote;
|
return note;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deactivateNote(noteId: number) {
|
async function deactivateNote(noteId: number) {
|
||||||
@ -182,19 +182,22 @@ class SusCommand extends Command {
|
|||||||
// Checks what subcommand was run
|
// Checks what subcommand was run
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'add': {
|
case 'add': {
|
||||||
return await this.addNote(interaction);
|
await this.addNote(interaction);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case 'view': {
|
case 'view': {
|
||||||
return await this.listNote(interaction);
|
await this.listNote(interaction);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case 'remove': {
|
case 'remove': {
|
||||||
return await this.removeNote(interaction);
|
await this.removeNote(interaction);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case 'purge': {
|
case 'purge': {
|
||||||
return await this.removeAllNotes(interaction);
|
await this.removeAllNotes(interaction);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
default: {
|
||||||
|
|
||||||
// If subcommand is invalid
|
// If subcommand is invalid
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'Invalid sub command!',
|
content: 'Invalid sub command!',
|
||||||
@ -202,9 +205,11 @@ class SusCommand extends Command {
|
|||||||
fetchReply: true,
|
fetchReply: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subcommand to add sus note
|
// Subcommand to add sus note
|
||||||
public async addNote(interaction: Command.ChatInputInteraction) {
|
private async addNote(interaction: Command.ChatInputInteraction) {
|
||||||
// Get the arguments
|
// Get the arguments
|
||||||
let user = interaction.options.getUser('user');
|
let user = interaction.options.getUser('user');
|
||||||
let note = interaction.options.getString('note');
|
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
|
// Get the arguments
|
||||||
let user = interaction.options.getUser('user');
|
let user = interaction.options.getUser('user');
|
||||||
const { guild } = interaction;
|
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
|
// Get the arguments
|
||||||
let noteId = interaction.options.getInteger('id');
|
let noteId = interaction.options.getInteger('id');
|
||||||
const { guild, channel } = interaction;
|
const { guild, channel } = interaction;
|
||||||
@ -439,7 +444,7 @@ class SusCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async removeAllNotes(interaction: Command.ChatInputInteraction) {
|
private async removeAllNotes(interaction: Command.ChatInputInteraction) {
|
||||||
// Get the arguments
|
// Get the arguments
|
||||||
const user = interaction.options.getUser('user');
|
const user = interaction.options.getUser('user');
|
||||||
const { guild, channel } = interaction;
|
const { guild, channel } = interaction;
|
||||||
|
@ -27,7 +27,7 @@ export async function userExists(user: GuildMember) {
|
|||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
// Counts if the user is on the database by their snowflake
|
// Counts if the user is on the database by their snowflake
|
||||||
const userExists = await prisma.user.count({
|
const userQuery = await prisma.user.count({
|
||||||
where: {
|
where: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
},
|
},
|
||||||
@ -37,10 +37,7 @@ export async function userExists(user: GuildMember) {
|
|||||||
await prisma.$disconnect();
|
await prisma.$disconnect();
|
||||||
|
|
||||||
// If the user is found on the database, then return true, otherwise, false.
|
// If the user is found on the database, then return true, otherwise, false.
|
||||||
if (userExists > 0) {
|
return userQuery > 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the user to the database if they were already on the server before the bot/database
|
// 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();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
// Counts if the user is on the database by their snowflake
|
// Counts if the user is on the database by their snowflake
|
||||||
const userExists = await prisma.user.count({
|
const userQuery = await prisma.user.count({
|
||||||
where: {
|
where: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the user is already in the database
|
// If the user is already in the database
|
||||||
if (userExists > 0) {
|
if (userQuery > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import devIDs from './devIDs';
|
import devIDs from './devIDs';
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-mutable-exports
|
||||||
let IDs = {
|
let IDs = {
|
||||||
roles: {
|
roles: {
|
||||||
trusted: '731563158011117590',
|
trusted: '731563158011117590',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user