Compare commits

..

9 Commits

Author SHA1 Message Date
lamp d9a1b9b99c disable broken 2022-04-01 23:05:40 -07:00
lamp 6fe26e7837 DEBUG AGAIN FUCK 2022-04-01 22:53:50 -07:00
lamp afc2b10a86 fix bug 2022-04-01 22:32:08 -07:00
lamp 3369bd521d DEBUG BITCH 2022-04-01 22:09:07 -07:00
lamp d52aff9936 ok 2022-04-01 22:03:00 -07:00
lamp a44f81bddf wtff 2022-04-01 21:56:31 -07:00
lamp 2925c3d788 recreate missing channel 2022-04-01 21:45:26 -07:00
lamp 9dcd27c45f wat 2022-04-01 21:04:39 -07:00
lamp e882ee7e57 fix private 2022-04-01 21:04:12 -07:00
+20 -11
View File
@@ -26,25 +26,33 @@ try {
} }
async function updateUserStatuses() { async function updateUserStatuses() {
for (let {channel, userId} of vrcul) { for (let x of vrcul) {
try { 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 status_icon = user.state == "online" ? status2icon[user.status] : '⚫';
let nn = `${status_icon} ${user.displayName}`; 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") { if (user.worldId && user.worldId != "offline") {
console.debug(user.worldId);
let bcn = `${await getWorldNameForId(user.worldId)}`; 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); await belowChannel.setName(bcn);
} else { } else {
let ch = await client.channels.resolve(config.vrchat_status_category).createChannel(`${await getWorldNameForId(user.worldId)}`, {type: "GUILD_VOICE", position: belowChannel.position}); let ch = await client.channels.resolve(config.vrchat_status_category).createChannel(`${await getWorldNameForId(user.worldId)}`, {type: "GUILD_VOICE", /*position: belowChannel.position*/});
//position option doesn't work? // position option is erratic
await ch.setPosition(channel.position); await ch.setPosition(channel.position + 1);
} }
} else if (belowChannel?.name.startsWith('┗')) { } else if (belowChannel?.name.startsWith('┗')) {
await belowChannel.delete(); await belowChannel.delete();
@@ -85,5 +93,6 @@ client.on("interactionCreate", async i => {
var worldnamecache = {}; var worldnamecache = {};
async function getWorldNameForId(worldId) { async function getWorldNameForId(worldId) {
if (worldId == "private") return "Private World";
return worldnamecache[worldId] = worldnamecache[worldId] || (await worldsApi.getWorld(worldId)).data.name; return worldnamecache[worldId] = worldnamecache[worldId] || (await worldsApi.getWorld(worldId)).data.name;
} }