Add ESLint and fix issues (#133)
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
84749c3381
commit
39529cf20c
44 changed files with 1590 additions and 280 deletions
|
@ -47,7 +47,7 @@ export default class CardDropHelperMetadata {
|
|||
};
|
||||
}
|
||||
|
||||
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: Number, imageFileName: string): EmbedBuilder {
|
||||
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string): EmbedBuilder {
|
||||
let description = "";
|
||||
description += `Series: ${drop.series.name}\n`;
|
||||
description += `Claimed: ${quantityClaimed}\n`;
|
||||
|
@ -68,7 +68,7 @@ export default class CardDropHelperMetadata {
|
|||
.setLabel("Claim")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`reroll`)
|
||||
.setCustomId("reroll")
|
||||
.setLabel("Reroll")
|
||||
.setStyle(ButtonStyle.Secondary));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
||||
import Inventory from "../database/entities/app/Inventory";
|
||||
import { CoreClient } from "../client/client";
|
||||
import SeriesMetadata from "../contracts/SeriesMetadata";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
import { CardRarity, CardRarityToString } from "../constants/CardRarity";
|
||||
|
||||
|
@ -37,14 +36,14 @@ export default class InventoryHelper {
|
|||
|
||||
const pages: InventoryPage[] = [];
|
||||
|
||||
for (let series of allSeriesClaimed) {
|
||||
for (const series of allSeriesClaimed) {
|
||||
const seriesCards = series.cards;
|
||||
|
||||
for (let i = 0; i < seriesCards.length; i+= cardsPerPage) {
|
||||
const cards = series.cards.slice(i, i + cardsPerPage);
|
||||
const pageCards: InventoryPageCards[] = [];
|
||||
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
const item = inventory.find(x => x.CardNumber == card.id);
|
||||
|
||||
if (!item) {
|
||||
|
@ -77,7 +76,7 @@ export default class InventoryHelper {
|
|||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(username)
|
||||
.setDescription(`**${currentPage.name} (${currentPage.seriesSubpage + 1})**\n${currentPage.cards.map(x => `[${x.id}] ${x.name} (${CardRarityToString(x.type)}) x${x.quantity}`).join('\n')}`)
|
||||
.setDescription(`**${currentPage.name} (${currentPage.seriesSubpage + 1})**\n${currentPage.cards.map(x => `[${x.id}] ${x.name} (${CardRarityToString(x.type)}) x${x.quantity}`).join("\n")}`)
|
||||
.setFooter({ text: `Page ${page + 1} of ${pages.length}` })
|
||||
.setColor(EmbedColours.Ok);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { QueryRunner } from "typeorm";
|
|||
|
||||
export default class MigrationHelper {
|
||||
public static Up(migrationName: string, version: string, queryFiles: string[], queryRunner: QueryRunner) {
|
||||
for (let path of queryFiles) {
|
||||
for (const path of queryFiles) {
|
||||
const query = readFileSync(`${process.cwd()}/database/${version}/${migrationName}/Up/${path}.sql`).toString();
|
||||
|
||||
queryRunner.query(query);
|
||||
|
@ -11,7 +11,7 @@ export default class MigrationHelper {
|
|||
}
|
||||
|
||||
public static Down(migrationName: string, version: string, queryFiles: string[], queryRunner: QueryRunner) {
|
||||
for (let path of queryFiles) {
|
||||
for (const path of queryFiles) {
|
||||
const query = readFileSync(`${process.cwd()}/database/${version}/${migrationName}/Down/${path}.sql`).toString();
|
||||
|
||||
queryRunner.query(query);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export default class StringTools {
|
||||
public static Capitalise(str: string): string {
|
||||
const words = str.split(" ");
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
|
||||
words.forEach(word => {
|
||||
const firstLetter = word.substring(0, 1).toUpperCase();
|
||||
|
@ -26,17 +26,17 @@ export default class StringTools {
|
|||
public static RandomString(length: number) {
|
||||
let result = "";
|
||||
|
||||
const characters = 'abcdefghkmnpqrstuvwxyz23456789';
|
||||
const characters = "abcdefghkmnpqrstuvwxyz23456789";
|
||||
const charactersLength = characters.length;
|
||||
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
for ( let i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ReplaceAll(str: string, find: string, replace: string) {
|
||||
return str.replace(new RegExp(find, 'g'), replace);
|
||||
return str.replace(new RegExp(find, "g"), replace);
|
||||
}
|
||||
}
|
|
@ -4,23 +4,23 @@ export default class TimeLengthInput {
|
|||
public readonly value: string;
|
||||
|
||||
constructor(input: string) {
|
||||
this.value = StringTools.ReplaceAll(input, ',', '');
|
||||
this.value = StringTools.ReplaceAll(input, ",", "");
|
||||
}
|
||||
|
||||
public GetDays(): number {
|
||||
return this.GetValue('d');
|
||||
return this.GetValue("d");
|
||||
}
|
||||
|
||||
public GetHours(): number {
|
||||
return this.GetValue('h');
|
||||
return this.GetValue("h");
|
||||
}
|
||||
|
||||
public GetMinutes(): number {
|
||||
return this.GetValue('m');
|
||||
return this.GetValue("m");
|
||||
}
|
||||
|
||||
public GetSeconds(): number {
|
||||
return this.GetValue('s');
|
||||
return this.GetValue("s");
|
||||
}
|
||||
|
||||
public GetMilliseconds(): number {
|
||||
|
@ -106,7 +106,7 @@ export default class TimeLengthInput {
|
|||
}
|
||||
|
||||
private GetValue(designation: string): number {
|
||||
const valueSplit = this.value.split(' ');
|
||||
const valueSplit = this.value.split(" ");
|
||||
|
||||
const desString = valueSplit.find(x => x.charAt(x.length - 1) == designation);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue