From b986f9862cf9fd4653fed21e1335916d35ffb2b3 Mon Sep 17 00:00:00 2001 From: Kath Date: Wed, 31 Jul 2024 17:11:27 +0800 Subject: [PATCH] fix oversite --- eslint.config.js | 4 ++-- src/commands/automod.ts | 1 + src/commands/user.ts | 18 ++++++++++++------ src/functions/CheckPermits.ts | 3 +-- src/functions/Infraction.ts | 10 ++++++---- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index a1893f6..461c61e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,5 @@ import prettier from 'eslint-config-prettier'; import ts from 'typescript-eslint'; -import { Guild } from 'discord.js'; import globals from 'globals'; export default [ @@ -14,7 +13,7 @@ export default [ globals: { ...globals.es2022, ...globals.node, - guild: Guild + guild: 'writable' } }, rules: { @@ -46,6 +45,7 @@ export default [ 'default-case-last': 'warn', 'no-self-compare': 'error', 'no-new-wrappers': 'error', + 'no-fallthrough': 'error', 'no-lone-blocks': 'error', 'no-undef-init': 'error', 'no-else-return': 'warn', diff --git a/src/commands/automod.ts b/src/commands/automod.ts index d9dfe1c..3039f7d 100644 --- a/src/commands/automod.ts +++ b/src/commands/automod.ts @@ -96,6 +96,7 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise }); } } + break; } default: { await interaction.reply({ content: 'Invalid subcommand Please provide a valid subcommand', ephemeral: true }); diff --git a/src/commands/user.ts b/src/commands/user.ts index d032325..7e82df1 100644 --- a/src/commands/user.ts +++ b/src/commands/user.ts @@ -67,11 +67,14 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise .setTimestamp() .setColor(0xff8c00) .setDescription( - `<@${user.id}>\n\nBot: ${user.user.bot}\nID: ${user.id}\n Created: ()\nJoined: ()\nRoles: ${user.roles.cache.map((role) => `<@&${role.id}>`)}` + `<@${user.id}>\n\nBot: ${user.user.bot}\nID: ${user.id}\n Created: ()\nJoined: ()\nRoles: ${user.roles.cache + .map((role) => `<@&${role.id}>`) + .filter((role) => role !== `<@&${interaction.guild?.id}>`) + .join(', ')}` ); await interaction.reply({ embeds: [embed], @@ -84,7 +87,7 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise ], ephemeral: true }); - await interaction.reply({ content: `<@${user.id}> has been warned`, ephemeral: true }); + break; } case 'infractions': { const userInfractions = await getUserInfractions(commandUser.id); @@ -102,6 +105,7 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise .setColor(0xff8c00) .setTimestamp(); await interaction.reply({ embeds: [embed], ephemeral: true }); + break; } case 'warn': { const reason = interaction.options.getString('reason') || 'No reason provided'; @@ -115,6 +119,7 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise .log() .save(); await interaction.reply({ content: `<@${commandUser.id}> has been warned`, ephemeral: true }); + break; } case 'kick': { const reason = interaction.options.getString('reason') || 'No reason provided'; @@ -128,6 +133,7 @@ export async function execute(interaction: ChatInputCommandInteraction): Promise .log() .save(); await interaction.reply({ content: `<@${commandUser.id}> has been kicked`, ephemeral: true }); + break; } default: { await interaction.reply({ content: 'Invalid subcommand Please provide a valid subcommand', ephemeral: true }); diff --git a/src/functions/CheckPermits.ts b/src/functions/CheckPermits.ts index b75c677..fba0712 100644 --- a/src/functions/CheckPermits.ts +++ b/src/functions/CheckPermits.ts @@ -1,9 +1,8 @@ import { autoModBypassRole } from '../../config.json'; import { readFileSync, writeFileSync } from 'fs'; import { UserPermit } from '../commands/automod'; -import { Client } from 'discord.js'; -export default async function CheckPermits(client: Client) { +export default function CheckPermits() { const permitData = readFileSync('data/permit.json'); if (!permitData) return; const permit = JSON.parse(permitData.toString()); diff --git a/src/functions/Infraction.ts b/src/functions/Infraction.ts index 64aa816..0d9531a 100644 --- a/src/functions/Infraction.ts +++ b/src/functions/Infraction.ts @@ -1,5 +1,5 @@ -import { ChannelType } from 'discord.js'; import { infractionLogchannel } from '../../config.json'; +import { ChannelType } from 'discord.js'; import { model, Schema } from 'mongoose'; export interface InfractionUser { @@ -81,9 +81,11 @@ class Infraction { return this.infraction.automatic; } public toString(): string { - return `Infraction: ${this.infraction.reason}\nAutomatic: ${this.infraction.automatic ? 'Yes' : 'No'}\nUser: <@${ - this.infraction.user.id - }>\nStaff: ${this.infraction.staff ? `<@${this.infraction.staff.id}>` : 'None'}`; + return `Infraction: ${this.infraction.reason}\nType: ${this.infraction.type}\nAutomatic: ${ + this.infraction.automatic ? 'Yes' : 'No' + }\nUser: <@${this.infraction.user.id}>\nStaff: ${ + this.infraction.staff ? `<@${this.infraction.staff.id}>` : 'None' + }`; } public log(): this { const channel = guild.channels.cache.get(infractionLogchannel);