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
|
@ -6,9 +6,9 @@ export default class About extends Command {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('about')
|
||||
.setDescription('About Bot');
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName("about")
|
||||
.setDescription("About Bot");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
|
|
|
@ -12,35 +12,33 @@ export default class Drop extends Command {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('drop')
|
||||
.setDescription('Summon a new card drop');
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName("drop")
|
||||
.setDescription("Summon a new card drop");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
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 });
|
||||
|
|
|
@ -9,37 +9,37 @@ export default class Gdrivesync extends Command {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('gdrivesync')
|
||||
.setDescription('Sync google drive to the bot')
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName("gdrivesync")
|
||||
.setDescription("Sync google drive to the bot")
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(',');
|
||||
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(",");
|
||||
|
||||
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
|
||||
await interaction.reply("Only whitelisted users can use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.reply('Syncing, this might take a while...');
|
||||
await interaction.reply("Syncing, this might take a while...");
|
||||
|
||||
CoreClient.AllowDrops = false;
|
||||
|
||||
exec(`rclone sync card-drop-gdrive: ${process.env.DATA_DIR}/cards`, async (error: ExecException | null) => {
|
||||
if (error) {
|
||||
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
|
||||
await Config.SetValue('safemode', 'true');
|
||||
await Config.SetValue("safemode", "true");
|
||||
} else {
|
||||
await CardMetadataFunction.Execute();
|
||||
|
||||
await interaction.editReply('Synced successfully.');
|
||||
await interaction.editReply("Synced successfully.");
|
||||
|
||||
CoreClient.AllowDrops = true;
|
||||
await Config.SetValue('safemode', 'false');
|
||||
await Config.SetValue("safemode", "false");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@ export default class Inventory extends Command {
|
|||
super();
|
||||
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('inventory')
|
||||
.setDescription('View your inventory')
|
||||
.setName("inventory")
|
||||
.setDescription("View your inventory")
|
||||
.addNumberOption(x =>
|
||||
x
|
||||
.setName('page')
|
||||
.setDescription('The page to start with'));
|
||||
.setName("page")
|
||||
.setDescription("The page to start with"));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
const page = interaction.options.get('page');
|
||||
const page = interaction.options.get("page");
|
||||
|
||||
try {
|
||||
let pageNumber = 0;
|
||||
|
|
|
@ -7,27 +7,27 @@ export default class Resync extends Command {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('resync')
|
||||
.setDescription('Resync the card database')
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName("resync")
|
||||
.setDescription("Resync the card database")
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(',');
|
||||
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(",");
|
||||
|
||||
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
|
||||
await interaction.reply("Only whitelisted users can use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
let result = await CardMetadataFunction.Execute(true);
|
||||
const result = await CardMetadataFunction.Execute(true);
|
||||
|
||||
if (result) {
|
||||
if (await Config.GetValue('safemode') == "true") {
|
||||
await Config.SetValue('safemode', 'false');
|
||||
if (await Config.GetValue("safemode") == "true") {
|
||||
await Config.SetValue("safemode", "false");
|
||||
await interaction.reply("Resynced database and disabled safe mode.");
|
||||
|
||||
return;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue