Polarcraft/discordbot/functions/utils.js

17 lines
471 B
JavaScript
Raw Normal View History

2023-08-05 11:16:18 +02:00
const applyUsername = async (user, member) => {
let rawUsername = member.user.globalName;
if (user.useMinecraftUsername && user.minecraftUUID) {
const response = await fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${user.minecraftUUID}`);
const minecraftProfile = await response.json();
rawUsername = minecraftProfile.name;
}
await member.setNickname(rawUsername);
return rawUsername;
};
module.exports = { applyUsername };