Skip to content

Commit

Permalink
test: add debug log for guildmember and user
Browse files Browse the repository at this point in the history
  • Loading branch information
skinmaker1345 committed Mar 5, 2024
1 parent edc7c94 commit 3a8b5de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions utils/DiscordBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ DiscordBot.on('ready', async () => {
DiscordBot.login(process.env.DISCORD_TOKEN ?? '')
ServerListDiscordBot.login(process.env.DISCORD_SERVERLIST_TOKEN)

DiscordBot.on('debug', console.info)

export const getMainGuild = () => DiscordBot.guilds.cache.get(process.env.GUILD_ID ?? '')

export const discordLog = async (
Expand Down
12 changes: 10 additions & 2 deletions utils/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ async function getBot(id: string, topLevel = true): Promise<Bot> {
if (!discordBot) return null
const botMember = (await getMainGuild()
?.members?.fetch(res[0].id)
.catch((e) => e)) as GuildMember
.catch((e) => {
console.log(`Failed to fetch member ${res[0].id}`)
console.error(e)
return null
})) as GuildMember | null
const name = discordBot.displayName
res[0].flags =
res[0].flags |
Expand Down Expand Up @@ -794,7 +798,11 @@ async function getDiscordUser(id: string): Promise<DiscordUser> {
return await DiscordBot.users
.fetch(id)
.then((u) => u)
.catch(() => null)
.catch((e) => {
console.log(`Could not fetch a user from Discord, ${id}`)
console.error(e)
return null
})
}

/**
Expand Down

0 comments on commit 3a8b5de

Please sign in to comment.