From 808314701e2ea8dbcf9419466bfd6da1ec5faabb Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 3 Jan 2024 18:29:34 +0000 Subject: [PATCH] Fix eslint issues --- .eslintrc.json | 11 ++++++++++- src/buttonEvents/Reroll.ts | 6 ++---- src/client/client.ts | 8 +++----- src/client/interactionCreate/Button.ts | 2 +- src/client/util.ts | 5 ++--- src/commands/drop.ts | 4 +--- .../{IButtonEventItem.ts => ButtonEventItem.ts} | 6 ++++-- 7 files changed, 23 insertions(+), 19 deletions(-) rename src/contracts/{IButtonEventItem.ts => ButtonEventItem.ts} (74%) diff --git a/.eslintrc.json b/.eslintrc.json index 6b391e4..29f04b8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -32,5 +32,14 @@ "error", "always" ] - } + }, + "globals": { + "jest": true, + "require": true, + "exports": true, + "process": true + }, + "ignorePatterns": [ + "dist/**/*" + ] } diff --git a/src/buttonEvents/Reroll.ts b/src/buttonEvents/Reroll.ts index f353b24..fa60c97 100644 --- a/src/buttonEvents/Reroll.ts +++ b/src/buttonEvents/Reroll.ts @@ -1,4 +1,4 @@ -import { AttachmentBuilder, ButtonInteraction, DiscordAPIError } from "discord.js"; +import { AttachmentBuilder, ButtonInteraction } from "discord.js"; import { ButtonEvent } from "../type/buttonEvent"; import { readFileSync } from "fs"; import { v4 } from "uuid"; @@ -28,11 +28,9 @@ export default class Reroll extends ButtonEvent { } try { - let image: Buffer; + const image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path)); const imageFileName = randomCard.card.path.split("/").pop()!; - image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path)); - await interaction.deferReply(); const attachment = new AttachmentBuilder(image, { name: imageFileName }); diff --git a/src/client/client.ts b/src/client/client.ts index 0dbd3d1..ca2fba3 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -1,20 +1,18 @@ import { Client, DMChannel, Guild, GuildBan, GuildMember, Message, NonThreadGuildBasedChannel, PartialGuildMember, PartialMessage } from "discord.js"; import * as dotenv from "dotenv"; -import { EventType } from "../constants/EventType"; import ICommandItem from "../contracts/ICommandItem"; import EventExecutors from "../contracts/EventExecutors"; import { Command } from "../type/command"; import { Events } from "./events"; import { Util } from "./util"; -import IButtonEventItem from "../contracts/IButtonEventItem"; +import IButtonEventItem from "../contracts/ButtonEventItem"; import { ButtonEvent } from "../type/buttonEvent"; import AppDataSource from "../database/dataSources/appDataSource"; import { Environment } from "../constants/Environment"; import Webhooks from "../webhooks"; import CardMetadataFunction from "../Functions/CardMetadataFunction"; import { SeriesMetadata } from "../contracts/SeriesMetadata"; -import InventoryHelper from "../helpers/InventoryHelper"; export class CoreClient extends Client { private static _commandItems: ICommandItem[]; @@ -90,7 +88,7 @@ export class CoreClient extends Client { ServerId: serverId, }; - if (environment &= CoreClient.Environment) { + if ((environment & CoreClient.Environment) == CoreClient.Environment) { CoreClient._commandItems.push(item); } } @@ -354,7 +352,7 @@ export class CoreClient extends Client { Environment: environment, }; - if (environment &= CoreClient.Environment) { + if ((environment & CoreClient.Environment) == CoreClient.Environment) { CoreClient._buttonEvents.push(item); } } diff --git a/src/client/interactionCreate/Button.ts b/src/client/interactionCreate/Button.ts index ce71b46..fac2b78 100644 --- a/src/client/interactionCreate/Button.ts +++ b/src/client/interactionCreate/Button.ts @@ -1,4 +1,4 @@ -import { ButtonInteraction, Interaction } from "discord.js"; +import { ButtonInteraction } from "discord.js"; import { CoreClient } from "../client"; export default class Button { diff --git a/src/client/util.ts b/src/client/util.ts index 9720a7b..ddd84fc 100644 --- a/src/client/util.ts +++ b/src/client/util.ts @@ -1,5 +1,4 @@ import { Client, REST, Routes, SlashCommandBuilder } from "discord.js"; -import { EventType } from "../constants/EventType"; import EventExecutors from "../contracts/EventExecutors"; import { CoreClient } from "./client"; @@ -15,7 +14,7 @@ export class Util { for (const command of globalCommands) { if (!command.Command.CommandBuilder) continue; - if (command.Environment &= CoreClient.Environment) { + if ((command.Environment & CoreClient.Environment) == CoreClient.Environment) { globalCommandData.push(command.Command.CommandBuilder); } } @@ -43,7 +42,7 @@ export class Util { for (const command of guildCommands.filter(x => x.ServerId == guild)) { if (!command.Command.CommandBuilder) continue; - if (command.Environment &= CoreClient.Environment) { + if ((command.Environment & CoreClient.Environment) == CoreClient.Environment) { guildCommandData.push(command.Command.CommandBuilder); } } diff --git a/src/commands/drop.ts b/src/commands/drop.ts index c2a613c..4fd1ddb 100644 --- a/src/commands/drop.ts +++ b/src/commands/drop.ts @@ -36,11 +36,9 @@ export default class Drop extends Command { } try { - let image: Buffer; + const image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path)); const imageFileName = randomCard.card.path.split("/").pop()!; - image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path)); - await interaction.deferReply(); const attachment = new AttachmentBuilder(image, { name: imageFileName }); diff --git a/src/contracts/IButtonEventItem.ts b/src/contracts/ButtonEventItem.ts similarity index 74% rename from src/contracts/IButtonEventItem.ts rename to src/contracts/ButtonEventItem.ts index 061a9c9..e139334 100644 --- a/src/contracts/IButtonEventItem.ts +++ b/src/contracts/ButtonEventItem.ts @@ -1,8 +1,10 @@ import { Environment } from "../constants/Environment"; import { ButtonEvent } from "../type/buttonEvent"; -export default interface IButtonEventItem { +interface ButtonEventItem { ButtonId: string, Event: ButtonEvent, Environment: Environment, -} \ No newline at end of file +} + +export default ButtonEventItem; \ No newline at end of file