【发布时间】:2021-11-04 12:17:53
【问题描述】:
所以我正在尝试为我的机器人创建一个命令,将 Minecraft 用户名转换为uuid,当用户名无法识别时,mojang API 返回 NO 数据,有没有办法检查没有我的机器人崩溃了?
fetch(`https://api.mojang.com/users/profiles/minecraft/${username}?`)
.then(Result => Result.json())
.then(async mojang => {
if (mojang.empty) {
return interaction.reply({content:`No user by the name of **${username}** was found`, ephemeral: true})
}
【问题讨论】:
标签: javascript node.js discord.js node-fetch