Compare commits
No commits in common. "eda5d9688444dc7f9bbe7ac92e14189778dbabfd" and "875a4dc5655c4dc313d3c833399bcdaa1431a419" have entirely different histories.
eda5d96884
...
875a4dc565
9 changed files with 5 additions and 103 deletions
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=0.8.1
|
BOT_VER=0.8.0
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=682942374040961060
|
BOT_CLIENTID=682942374040961060
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "card-drop",
|
"name": "card-drop",
|
||||||
"version": "0.8.1",
|
"version": "0.8.0",
|
||||||
"main": "./dist/bot.js",
|
"main": "./dist/bot.js",
|
||||||
"typings": "./dist",
|
"typings": "./dist",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { glob } from "glob";
|
||||||
import { SeriesMetadata } from "../contracts/SeriesMetadata";
|
import { SeriesMetadata } from "../contracts/SeriesMetadata";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import AppLogger from "../client/appLogger";
|
import AppLogger from "../client/appLogger";
|
||||||
import {CardRarity} from "../constants/CardRarity";
|
|
||||||
|
|
||||||
export interface CardMetadataResult {
|
export interface CardMetadataResult {
|
||||||
IsSuccess: boolean;
|
IsSuccess: boolean;
|
||||||
|
@ -38,22 +37,7 @@ export default class CardMetadataFunction {
|
||||||
|
|
||||||
if (cardResult.IsSuccess) {
|
if (cardResult.IsSuccess) {
|
||||||
CoreClient.Cards = cardResult.Result!;
|
CoreClient.Cards = cardResult.Result!;
|
||||||
|
AppLogger.LogInfo("Functions/CardMetadataFunction", `Loaded ${CoreClient.Cards.flatMap(x => x.cards).length} cards to database`);
|
||||||
const allCards = CoreClient.Cards.flatMap(x => x.cards);
|
|
||||||
|
|
||||||
const totalCards = allCards.length;
|
|
||||||
const bronzeCards = allCards.filter(x => x.type == CardRarity.Bronze)
|
|
||||||
.length;
|
|
||||||
const silverCards = allCards.filter(x => x.type == CardRarity.Silver)
|
|
||||||
.length;
|
|
||||||
const goldCards = allCards.filter(x => x.type == CardRarity.Gold)
|
|
||||||
.length;
|
|
||||||
const mangaCards = allCards.filter(x => x.type == CardRarity.Manga)
|
|
||||||
.length;
|
|
||||||
const legendaryCards = allCards.filter(x => x.type == CardRarity.Legendary)
|
|
||||||
.length;
|
|
||||||
|
|
||||||
AppLogger.LogInfo("Functions/CardMetadataFunction", `Loaded ${totalCards} cards to database (${bronzeCards} bronze, ${silverCards} silver, ${goldCards} gold, ${mangaCards} manga, ${legendaryCards} legendary)`);
|
|
||||||
|
|
||||||
const duplicateCards = CoreClient.Cards.flatMap(x => x.cards)
|
const duplicateCards = CoreClient.Cards.flatMap(x => x.cards)
|
||||||
.filter((card, index, self) => self.findIndex(c => c.id === card.id) !== index);
|
.filter((card, index, self) => self.findIndex(c => c.id === card.id) !== index);
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
import {CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js";
|
|
||||||
import {Command} from "../type/command";
|
|
||||||
import {CoreClient} from "../client/client";
|
|
||||||
import {CardRarity} from "../constants/CardRarity";
|
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
|
||||||
|
|
||||||
export default class Stats extends Command {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.CommandBuilder = new SlashCommandBuilder()
|
|
||||||
.setName("stats")
|
|
||||||
.setDescription("Get bot stats such as card info")
|
|
||||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async execute(interaction: CommandInteraction) {
|
|
||||||
const allCards = CoreClient.Cards.flatMap(x => x.cards);
|
|
||||||
|
|
||||||
const totalCards = allCards.length;
|
|
||||||
const bronzeCards = allCards.filter(x => x.type == CardRarity.Bronze)
|
|
||||||
.length;
|
|
||||||
const silverCards = allCards.filter(x => x.type == CardRarity.Silver)
|
|
||||||
.length;
|
|
||||||
const goldCards = allCards.filter(x => x.type == CardRarity.Gold)
|
|
||||||
.length;
|
|
||||||
const mangaCards = allCards.filter(x => x.type == CardRarity.Manga)
|
|
||||||
.length;
|
|
||||||
const legendaryCards = allCards.filter(x => x.type == CardRarity.Legendary)
|
|
||||||
.length;
|
|
||||||
|
|
||||||
const description = [
|
|
||||||
`${totalCards} Total`,
|
|
||||||
`${bronzeCards} Bronze`,
|
|
||||||
`${silverCards} Silver`,
|
|
||||||
`${goldCards} Gold`,
|
|
||||||
`${mangaCards} Manga`,
|
|
||||||
`${legendaryCards} Legendary`,
|
|
||||||
].join("\n");
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setTitle("Stats")
|
|
||||||
.setDescription(description)
|
|
||||||
.setColor(EmbedColours.Ok);
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [ embed ],
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@ export interface CardMetadata {
|
||||||
type: CardRarity,
|
type: CardRarity,
|
||||||
path: string,
|
path: string,
|
||||||
subseries?: string,
|
subseries?: string,
|
||||||
colour?: string,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DropResult {
|
export interface DropResult {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { DropResult } from "../contracts/SeriesMetadata";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import AppLogger from "../client/appLogger";
|
import AppLogger from "../client/appLogger";
|
||||||
import CardConstants from "../constants/CardConstants";
|
import CardConstants from "../constants/CardConstants";
|
||||||
import StringTools from "./StringTools";
|
|
||||||
|
|
||||||
export default class CardDropHelperMetadata {
|
export default class CardDropHelperMetadata {
|
||||||
public static GetRandomCard(): DropResult | undefined {
|
public static GetRandomCard(): DropResult | undefined {
|
||||||
|
@ -83,25 +82,12 @@ export default class CardDropHelperMetadata {
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`);
|
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`);
|
||||||
|
|
||||||
const description = drop.card.subseries ?? drop.series.name;
|
const description = drop.card.subseries ?? drop.series.name;
|
||||||
let colour = CardRarityToColour(drop.card.type);
|
|
||||||
|
|
||||||
if (drop.card.colour && StringTools.IsHexCode(drop.card.colour)) {
|
|
||||||
const hexCode = Number("0x" + drop.card.colour);
|
|
||||||
|
|
||||||
if (hexCode) {
|
|
||||||
colour = hexCode;
|
|
||||||
} else {
|
|
||||||
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
|
||||||
}
|
|
||||||
} else if (drop.card.colour) {
|
|
||||||
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(drop.card.name)
|
.setTitle(drop.card.name)
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
||||||
.setColor(colour)
|
.setColor(CardRarityToColour(drop.card.type))
|
||||||
.setImage(`attachment://${imageFileName}`)
|
.setImage(`attachment://${imageFileName}`)
|
||||||
.addFields([
|
.addFields([
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default class SeriesHelper {
|
||||||
const cardsOnPage = series.cards.splice(page * itemsPerPage, itemsPerPage);
|
const cardsOnPage = series.cards.splice(page * itemsPerPage, itemsPerPage);
|
||||||
|
|
||||||
const description = cardsOnPage
|
const description = cardsOnPage
|
||||||
.map(x => `[${x.id}] ${x.name} (${CardRarityToString(x.type)})`)
|
.map(x => `[${x.id}] ${x.name} ${CardRarityToString(x.type).toUpperCase()}`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
|
|
|
@ -39,18 +39,4 @@ export default class StringTools {
|
||||||
public static ReplaceAll(str: string, find: string, replace: string) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IsHexCode(str: string): boolean {
|
|
||||||
if (str.length != 6) return false;
|
|
||||||
|
|
||||||
const characters = "0123456789abcdefABCDEF";
|
|
||||||
|
|
||||||
for (let i = 0; i < 6; i++) {
|
|
||||||
const char = str[i];
|
|
||||||
|
|
||||||
if (!characters.includes(char)) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@ import Inventory from "./commands/inventory";
|
||||||
import Resync from "./commands/resync";
|
import Resync from "./commands/resync";
|
||||||
import Sacrifice from "./commands/sacrifice";
|
import Sacrifice from "./commands/sacrifice";
|
||||||
import Series from "./commands/series";
|
import Series from "./commands/series";
|
||||||
import Stats from "./commands/stats";
|
|
||||||
import Trade from "./commands/trade";
|
import Trade from "./commands/trade";
|
||||||
import View from "./commands/view";
|
import View from "./commands/view";
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("resync", new Resync());
|
CoreClient.RegisterCommand("resync", new Resync());
|
||||||
CoreClient.RegisterCommand("sacrifice", new Sacrifice());
|
CoreClient.RegisterCommand("sacrifice", new Sacrifice());
|
||||||
CoreClient.RegisterCommand("series", new Series());
|
CoreClient.RegisterCommand("series", new Series());
|
||||||
CoreClient.RegisterCommand("stats", new Stats());
|
|
||||||
CoreClient.RegisterCommand("trade", new Trade());
|
CoreClient.RegisterCommand("trade", new Trade());
|
||||||
CoreClient.RegisterCommand("view", new View());
|
CoreClient.RegisterCommand("view", new View());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue