Create a getTachiIdByDiscordId stub

This commit is contained in:
Pfych
2021-09-25 12:29:18 +10:00
parent 332c838344
commit b72e9d1bbc
4 changed files with 14 additions and 4 deletions
+2 -1
View File
@@ -10,5 +10,6 @@ export enum LoggerLayers {
tachiFetch = "tachiFetch",
profile = "profile",
selectInteractionHandler = "selectInteractionHandler",
buildProfileEmbed = "buildProfileEmbed"
buildProfileEmbed = "buildProfileEmbed",
tachiLinker = "tachiLinker"
}
+2 -1
View File
@@ -2,6 +2,7 @@ import { CommandInteraction } from "discord.js";
import { IDStrings } from "tachi-common";
import { LoggerLayers } from "../config";
import { BotConfig } from "../setup";
import { getTachiIdByDiscordId } from "../utils/discord-to-tachi";
import { createLayeredLogger } from "../utils/logger";
import { stringToSimpleGameType } from "../utils/utils";
import { buildProfileIntractable } from "./buildProfileEmbed";
@@ -11,7 +12,7 @@ const logger = createLayeredLogger(LoggerLayers.profile);
export const getProfileByName = async (interaction: CommandInteraction): Promise<void> => {
try {
/** @TODO this can be an @User, userId or userName!!! Handle this at some point */
const userId = interaction.options.getString("user", false) || "TODO FALLBACK TO SELF";
const userId = interaction.options.getString("user", false) || getTachiIdByDiscordId(interaction.user.id);
logger.info(`Fetching user ${userId}`);
const optionalGameOption = <IDStrings | undefined>interaction.options.getString("game", false);
+10
View File
@@ -0,0 +1,10 @@
import { LoggerLayers } from "../config";
import { createLayeredLogger } from "./logger";
const logger = createLayeredLogger(LoggerLayers.tachiLinker);
/** @TODO Stub */
export const getTachiIdByDiscordId = (discordId: string): string => {
/** @TODO Hit an internal database to grab user id */
logger.info(`Fetching linked ID for ${discordId}`);
return "0";
};
-2
View File
@@ -29,7 +29,6 @@ export const getPfpUrl = (userId: number): string => {
return PrependTachiUrl(`/users/${userId}/pfp`);
};
/** @TODO @zkldi is there somewhere this exists already? */
export const gameIdentifierStrings = [
"iidx:SP",
"iidx:DP",
@@ -57,7 +56,6 @@ export const formatGameScoreRating = <I extends IDStrings = IDStrings>(
value: number
): string => {
const gptConfig = GetGamePTConfig(gpt.game, gpt.playtype);
/** @TODO UGSRatingsLookup should be able to cast to ScoreCalculatedDataLookup straight up */
const val = gptConfig.profileRatingAlgFormatters[ratingName];
if (val) {
return val(value);