Add ESLint and fix issues #133

Merged
Vylpes merged 7 commits from feature/49-eslint into develop 2024-01-05 19:26:44 +00:00
7 changed files with 23 additions and 19 deletions
Showing only changes of commit 808314701e - Show all commits

View file

@ -32,5 +32,14 @@
"error",
"always"
]
}
},
"globals": {
"jest": true,
"require": true,
"exports": true,
"process": true
},
"ignorePatterns": [
"dist/**/*"
]
}

View file

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

View file

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

View file

@ -1,4 +1,4 @@
import { ButtonInteraction, Interaction } from "discord.js";
import { ButtonInteraction } from "discord.js";
import { CoreClient } from "../client";
export default class Button {

View file

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

View file

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

View file

@ -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,
}
}
export default ButtonEventItem;