Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9a1b9b99c | |||
| 6fe26e7837 | |||
| afc2b10a86 | |||
| 3369bd521d | |||
| d52aff9936 | |||
| a44f81bddf | |||
| 2925c3d788 | |||
| 9dcd27c45f | |||
| e882ee7e57 |
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user