Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9a1b9b99c | |||
| 6fe26e7837 | |||
| afc2b10a86 | |||
| 3369bd521d | |||
| d52aff9936 | |||
| a44f81bddf | |||
| 2925c3d788 | |||
| 9dcd27c45f | |||
| e882ee7e57 | |||
| 20ecfb3e84 | |||
| 16f4b7eaf9 |
@@ -26,31 +26,40 @@ try {
|
||||
}
|
||||
|
||||
async function updateUserStatuses() {
|
||||
for (let {channel, userId} of vrcul) {
|
||||
for (let x of vrcul) {
|
||||
try {
|
||||
channel = client.channels.resolve(channel);
|
||||
let user = (await usersApi.getUser(userId)).data;
|
||||
|
||||
let user = (await usersApi.getUser(x.userId)).data;
|
||||
let status_icon = user.state == "online" ? status2icon[user.status] : '⚫';
|
||||
let nn = `${status_icon} ${user.displayName}`;
|
||||
if (nn != channel.name)
|
||||
await channel.setName(nn);
|
||||
|
||||
let belowChannel = client.channels.resolve(config.vrchat_status_category).children.find(x => x.position = channel.position + 1);
|
||||
var channel = client.channels.resolve(x.channel);
|
||||
if (!channel) {
|
||||
channel = await client.channels.resolve(config.vrchat_status_category).createChannel(nn, {type: "GUILD_VOICE"});
|
||||
x.channel = channel.id;
|
||||
fs.writeFileSync("data/vrcul.json", JSON.stringify(vrcul));
|
||||
} else if (nn != channel.name) {
|
||||
await channel.setName(nn);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
let belowChannel = client.channels.resolve(config.vrchat_status_category).children.find(x => x.position == channel.position + 1);
|
||||
if (user.worldId && user.worldId != "offline") {
|
||||
let bcn = `┗ ${await getWorldNameForId(user.worldId)}`;
|
||||
if (belowChannel && belowChannel.name.startsWith('┗') && belowChannel.name != bcn) {
|
||||
if (belowChannel && belowChannel.name.startsWith('┗') && belowChannel.name != bcn) { //todo debug
|
||||
await belowChannel.setName(bcn);
|
||||
} else {
|
||||
let ch = await client.channels.resolve(config.vrchat_status_category).createChannel(`┗ ${worldname}`, {type: "GUILD_VOICE", position: belowChannel.position});
|
||||
//position option doesn't work?
|
||||
await ch.setPosition(channel.position);
|
||||
let ch = await client.channels.resolve(config.vrchat_status_category).createChannel(`┗ ${await getWorldNameForId(user.worldId)}`, {type: "GUILD_VOICE", /*position: belowChannel.position*/});
|
||||
// position option is erratic
|
||||
await ch.setPosition(channel.position + 1);
|
||||
}
|
||||
} else if (belowChannel?.name.startsWith('┗')) {
|
||||
await belowChannel.delete();
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("vrcus", error.message);
|
||||
console.error("vrcus", error.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,5 +93,6 @@ client.on("interactionCreate", async i => {
|
||||
|
||||
var worldnamecache = {};
|
||||
async function getWorldNameForId(worldId) {
|
||||
if (worldId == "private") return "Private World";
|
||||
return worldnamecache[worldId] = worldnamecache[worldId] || (await worldsApi.getWorld(worldId)).data.name;
|
||||
}
|
||||
Reference in New Issue
Block a user