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

@ -11,23 +11,23 @@ export default class Dropnumber extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('dropnumber')
.setDescription('(TEST) Summon a specific card')
this.CommandBuilder = new SlashCommandBuilder()
.setName("dropnumber")
.setDescription("(TEST) Summon a specific card")
.addStringOption(x =>
x
.setName('cardnumber')
.setDescription('The card number to summon')
.setName("cardnumber")
.setDescription("The card number to summon")
.setRequired(true));
}
public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const cardNumber = interaction.options.get('cardnumber');
const cardNumber = interaction.options.get("cardnumber");
if (!cardNumber || !cardNumber.value) {
await interaction.reply('Card Number is required');
await interaction.reply("Card Number is required");
return;
}
@ -36,7 +36,7 @@ export default class Dropnumber extends Command {
.find(x => x.id == cardNumber.value);
if (!card) {
await interaction.reply('Card not found');
await interaction.reply("Card not found");
return;
}
@ -47,7 +47,7 @@ export default class Dropnumber extends Command {
const imageFileName = card.path.split("/").pop()!;
try {
image = readFileSync(path.join(process.env.DATA_DIR!, 'cards', card.path));
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
} catch {
await interaction.reply(`Unable to fetch image for card ${card.id}`);
return;
@ -78,7 +78,7 @@ export default class Dropnumber extends Command {
if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN`);
await interaction.editReply("Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN");
}
}

View file

@ -12,37 +12,37 @@ export default class Droprarity extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('droprarity')
.setDescription('(TEST) Summon a random card of a specific rarity')
this.CommandBuilder = new SlashCommandBuilder()
.setName("droprarity")
.setDescription("(TEST) Summon a random card of a specific rarity")
.addStringOption(x =>
x
.setName('rarity')
.setDescription('The rarity you want to summon')
.setName("rarity")
.setDescription("The rarity you want to summon")
.setRequired(true));
}
public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const rarity = interaction.options.get('rarity');
const rarity = interaction.options.get("rarity");
if (!rarity || !rarity.value) {
await interaction.reply('Rarity is required');
await interaction.reply("Rarity is required");
return;
}
const rarityType = CardRarityParse(rarity.value.toString());
if (rarityType == CardRarity.Unknown) {
await interaction.reply('Invalid rarity');
await interaction.reply("Invalid rarity");
return;
}
const card = await CardDropHelperMetadata.GetRandomCardByRarity(rarityType);
if (!card) {
await interaction.reply('Card not found');
await interaction.reply("Card not found");
return;
}
@ -50,7 +50,7 @@ export default class Droprarity extends Command {
const imageFileName = card.card.path.split("/").pop()!;
try {
image = readFileSync(path.join(process.env.DATA_DIR!, 'cards', card.card.path));
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
} catch {
await interaction.reply(`Unable to fetch image for card ${card.card.id}`);
return;
@ -81,7 +81,7 @@ export default class Droprarity extends Command {
if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN`);
await interaction.editReply("Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN");
}
}