Removed prefix as it was colliding with existing bot

This commit is contained in:
Alec LaLonde
2021-05-06 12:23:37 -06:00
committed by Alec LaLonde
parent 0b6e4aedde
commit 65b4d27ece
2 changed files with 19 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
import { CommandMessage, CommandNotFound, Discord } from '@typeit/discord';
import { Discord } from '@typeit/discord';
import * as Path from 'path';
@Discord('!', {
@Discord('', {
import: [
// We are using tsc, so we want to load the compiled files
Path.join(__dirname, "commands", "*.js"),
@@ -9,8 +9,8 @@ import * as Path from 'path';
})
export abstract class AppDiscord {
// This is triggered when a particular command doesn't exist
@CommandNotFound()
notFound(command: CommandMessage) {
command.reply("MetaGameBot doesn't recognize that command.");
}
// @CommandNotFound()
// notFound(command: CommandMessage) {
// command.reply("MetaGameBot doesn't recognize that command.");
// }
}

View File

@@ -8,7 +8,7 @@ import { getDiscordId, replyWithUnexpectedError } from "../../utils";
export class GetXpCommand {
// todo rename to xp once previous bot is disabled
@Command('getxp :discordUser')
@Command('!xp :discordUser')
async getXp(message: CommandMessage) {
let targetUserDiscordId = '';
try {
@@ -37,11 +37,11 @@ export class GetXpCommand {
const scAccount = accountsData.accounts.find(account => filterAccount(account, targetUserDiscordId));
if (scAccount != null) {
const userTotalCred = scAccount.totalCred;
const lengthArray = scAccount.cred.length;
const numWeeks = scAccount.cred.length;
const userWeeklyCred = scAccount.cred;
const variation =
(100 * (userWeeklyCred[lengthArray - 1] - userWeeklyCred[lengthArray - 2])) /
userWeeklyCred[lengthArray - 2];
(100 * (userWeeklyCred[numWeeks - 1] - userWeeklyCred[numWeeks - 2])) /
userWeeklyCred[numWeeks - 2];
const description = message.member?.id === targetUserDiscordId ?
`${discordUser}, here is your XP progression in MetaGame` :
@@ -50,7 +50,7 @@ export class GetXpCommand {
await message.reply(new MessageEmbed()
.setColor('#ff3864')
.setDescription(description)
.setTitle(`MetaGame XP Ledger`)
.setTitle(`MetaGame XP`)
.setURL("https://xp.metagame.wtf/#/explorer")
.setTimestamp()
.setThumbnail(
@@ -64,12 +64,12 @@ export class GetXpCommand {
},
{
name: 'Last week ',
value: `${userWeeklyCred[lengthArray - 1].toPrecision(3)} XP`,
value: `${userWeeklyCred[numWeeks - 1].toPrecision(3)} XP`,
inline: true,
},
{
name: 'Week before',
value: `${userWeeklyCred[lengthArray - 2].toPrecision(4)} XP`,
value: `${userWeeklyCred[numWeeks - 2].toPrecision(4)} XP`,
inline: true,
},
{
@@ -98,15 +98,16 @@ const filterAccount = (player: SCAccount, targetUserDiscordID: Snowflake) => {
// Ignore if the target isn't a USER
if (accountInfo.identity.subtype !== 'USER') return false;
const discordAlias = accountInfo.identity.aliases.filter(
const discordAliases = accountInfo.identity.aliases.filter(
alias => {
const parts = sc.core.graph.NodeAddress.toParts(alias.address);
return parts.indexOf('discord') > 0
});
}
);
if (discordAlias.length >= 1) {
if (discordAliases.length >= 1) {
// Retrieve the Discord ID
const discordId = discordAlias.find(discordAccount => filterMultipleDiscordAccounts(discordAccount, targetUserDiscordID));
const discordId = discordAliases.find(discordAccount => scAliasMatchesDiscordId(discordAccount, targetUserDiscordID));
if (discordId !== undefined){
return accountInfo;
}
@@ -114,7 +115,7 @@ const filterAccount = (player: SCAccount, targetUserDiscordID: Snowflake) => {
return false;
}
const filterMultipleDiscordAccounts = (discordAccount: SCAlias, targetUserDiscordID: Snowflake) => {
const scAliasMatchesDiscordId = (discordAccount: SCAlias, targetUserDiscordID: Snowflake) => {
const discordId = sc.core.graph.NodeAddress.toParts(discordAccount.address)[4];
if (discordId === targetUserDiscordID) {
return discordId;