feat: catch error when fetching user (#569)

This commit is contained in:
SKINMAKER 2023-06-20 20:54:18 +09:00 committed by GitHub
parent bec6aa3554
commit 50168f6cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -433,7 +433,7 @@ async function submitBot(id: string, data: AddBotSubmit):Promise<1|2|3|4|5|Submi
const sameID = await knex('submitted').select(['id']).where({ id: botId, state: 0 }) const sameID = await knex('submitted').select(['id']).where({ id: botId, state: 0 })
const bot = await get.bot.load(data.id) const bot = await get.bot.load(data.id)
if(sameID.length !== 0 || bot) return 2 if(sameID.length !== 0 || bot) return 2
const user = await DiscordBot.users.fetch(data.id) const user = await DiscordBot.users.fetch(data.id).catch(() => false)
if(!user) return 3 if(!user) return 3
const member = await getMainGuild().members.fetch(id).then(() => true).catch(() => false) const member = await getMainGuild().members.fetch(id).then(() => true).catch(() => false)
if(!member) return 4 if(!member) return 4