Add ESLint and fix issues (#133)
All checks were successful
continuous-integration/drone/push Build is passing

# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add ESLint to the project
- Fix issues which ESLint found

#49

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/133
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Ethan Lane 2024-01-05 19:26:44 +00:00 committed by Vylpes
parent 84749c3381
commit 39529cf20c
44 changed files with 1590 additions and 280 deletions

View file

@ -8,20 +8,20 @@ export default class Claim extends ButtonEvent {
public override async execute(interaction: ButtonInteraction) {
if (!interaction.guild || !interaction.guildId) return;
const cardNumber = interaction.customId.split(' ')[1];
const claimId = interaction.customId.split(' ')[2];
const droppedBy = interaction.customId.split(' ')[3];
const cardNumber = interaction.customId.split(" ")[1];
const claimId = interaction.customId.split(" ")[2];
const droppedBy = interaction.customId.split(" ")[3];
const userId = interaction.user.id;
const claimed = await eClaim.FetchOneByClaimId(claimId);
if (claimed) {
await interaction.reply('This card has already been claimed');
await interaction.reply("This card has already been claimed");
return;
}
if (claimId == CoreClient.ClaimId && userId != droppedBy) {
await interaction.reply('The latest dropped card can only be claimed by the user who dropped it');
await interaction.reply("The latest dropped card can only be claimed by the user who dropped it");
return;
}

View file

@ -4,8 +4,8 @@ import InventoryHelper from "../helpers/InventoryHelper";
export default class Inventory extends ButtonEvent {
public override async execute(interaction: ButtonInteraction) {
const userid = interaction.customId.split(' ')[1];
const page = interaction.customId.split(' ')[2];
const userid = interaction.customId.split(" ")[1];
const page = interaction.customId.split(" ")[2];
try {
const embed = await InventoryHelper.GenerateInventoryPage(interaction.user.username, userid, Number(page));

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";
@ -11,28 +11,26 @@ import path from "path";
export default class Reroll extends ButtonEvent {
public override async execute(interaction: ButtonInteraction) {
if (!CoreClient.AllowDrops) {
await interaction.reply('Bot is currently syncing, please wait until its done.');
await interaction.reply("Bot is currently syncing, please wait until its done.");
return;
}
if (await Config.GetValue('safemode') == "true") {
await interaction.reply('Safe Mode has been activated, please resync to continue.');
if (await Config.GetValue("safemode") == "true") {
await interaction.reply("Safe Mode has been activated, please resync to continue.");
return;
}
const randomCard = CardDropHelperMetadata.GetRandomCard();
if (!randomCard) {
await interaction.reply('Unable to fetch card, please try again.');
await interaction.reply("Unable to fetch card, please try again.");
return;
}
try {
let image: Buffer;
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path));
const imageFileName = randomCard.card.path.split("/").pop()!;
image = readFileSync(path.join(process.env.DATA_DIR!, 'cards', randomCard.card.path));
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: imageFileName });