Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
fetch in case user is not cached already
Browse files Browse the repository at this point in the history
  • Loading branch information
dhawton committed Apr 22, 2021
1 parent 462f9e0 commit 7fd2857
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import Rcon from "rcon";
import Log from "./Log";

class Utils {
static linkDiscord(client: Client, message: Discord.Message, data: DiscordLink): void {
static async linkDiscord(client: Client, message: Discord.Message, data: DiscordLink): Promise<void> {
const license = "%" + data.license.replace("license:", "");
const username = client.users.cache.get(data.discord).tag;
await client.users.fetch(data.discord);
let username = client.users.cache.get(data.discord)?.tag || "";

client.db.getPool().execute("UPDATE `users` SET `discord`=?, `discordid`=? WHERE `identifier` LIKE ?", [username, data.discord, license], (err) => {
if (err) {
Expand Down

0 comments on commit 7fd2857

Please sign in to comment.