Skip to content

Commit

Permalink
feat: add fullname
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Feb 2, 2024
1 parent 6a062cf commit 63b92b9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
ENABLE_BETS: ${ENABLE_BETS}
FORCE_RECAPS: ${FORCE_RECAPS}
HTTP_PORT: ${HTTP_PORT}

restart: always
depends_on:
- postgresql
networks:
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manageSummoners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ManageSummoner {
const riotSummoner = await getSummonerByName(name, tag || "EUW");

await addSummoner(riotSummoner, interaction.channelId);
interaction.reply("Added summoner " + name + "#" + tag || "EUW");
interaction.reply("Added summoner " + name + "#" + (tag || "EUW"));
} catch (e) {
console.log(e);
interaction.reply("Summoner not found");
Expand Down
6 changes: 3 additions & 3 deletions src/features/lol/elo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const checkElo = async () => {
export const checkSummonerElo = async (summ: SummonerWithChannels) => {
const summonerData = await getSummonerData(summ.puuid);

if (summonerData.name !== summ.currentName) {
await db.update(summoner).set({ currentName: summonerData.name }).where(eq(summoner.puuid, summ.puuid));
if (summonerData.fullname !== summ.currentName) {
await db.update(summoner).set({ currentName: summonerData.fullname }).where(eq(summoner.puuid, summ.puuid));
}

const elo = await getSoloQElo(summ.id);
Expand All @@ -58,7 +58,7 @@ export const checkSummonerElo = async (summ: SummonerWithChannels) => {

await db
.update(summoner)
.set({ icon: summonerData.profileIconId, currentName: summonerData.name, checkedAt: new Date() })
.set({ icon: summonerData.profileIconId, currentName: summonerData.fullname, checkedAt: new Date() })
.where(eq(summoner.puuid, summ.puuid));

if (lastRank && areRanksEqual(lastRank, newRank)) return;
Expand Down
3 changes: 2 additions & 1 deletion src/features/lol/summoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { addRequest, galeforce } from "../summoner";

export const getSummonerData = async (puuid: string) => {
const summonerData = await galeforce.lol.summoner().region(galeforce.region.lol.EUROPE_WEST).puuid(puuid).exec();
const account = await galeforce.riot.account.account().region(galeforce.region.riot.EUROPE).puuid(puuid).exec();
await addRequest();
return summonerData;
return { ...summonerData, fullname: `${account.gameName}#${account.tagLine}` };
};

export const getElos = async (id: string) => {
Expand Down
11 changes: 7 additions & 4 deletions src/features/summoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getSummonerByName = async (name: string, tag: string) => {
.region(galeforce.region.lol.EUROPE_WEST)
.puuid(account.puuid)
.exec();
return summoner;
return { ...summoner, fullname: `${account.gameName}#${account.tagLine}` };
};

export const getQueueRank = async (tier: Galeforce.Tier) => {
Expand All @@ -42,7 +42,10 @@ export const getQueueRank = async (tier: Galeforce.Tier) => {
return queue;
};

export const addSummoner = async (riotSummoner: Galeforce.dto.SummonerDTO, channelId: string) => {
export const addSummoner = async (
riotSummoner: Galeforce.dto.SummonerDTO & { fullname: string },
channelId: string
) => {
try {
const identifier = { puuid: summoner.puuid, channelId };

Expand All @@ -56,7 +59,7 @@ export const addSummoner = async (riotSummoner: Galeforce.dto.SummonerDTO, chann
if (existing) {
await db
.update(summoner)
.set({ isActive: true, currentName: riotSummoner.name })
.set({ isActive: true, currentName: riotSummoner.fullname })
.where(eq(summoner.puuid, riotSummoner.puuid));

return identifier;
Expand All @@ -67,7 +70,7 @@ export const addSummoner = async (riotSummoner: Galeforce.dto.SummonerDTO, chann
id: riotSummoner.id,
channelId,
icon: riotSummoner.profileIconId,
currentName: riotSummoner.name,
currentName: riotSummoner.fullname,
});

return identifier;
Expand Down

0 comments on commit 63b92b9

Please sign in to comment.