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;
|
|
|
|
}
|
|
|
|
|
2023-08-05 12:21:30 +02:00
|
|
|
user.rawUsername = rawUsername;
|
|
|
|
|
|
|
|
await user.save();
|
2023-08-05 11:16:18 +02:00
|
|
|
await member.setNickname(rawUsername);
|
|
|
|
|
|
|
|
return rawUsername;
|
|
|
|
};
|
|
|
|
|
2023-08-05 12:21:30 +02:00
|
|
|
const getUsername = (user) => {
|
|
|
|
return user.rawUsername;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = { applyUsername, getUsername };
|