Compare commits

..

19 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
lamp 20ecfb3e84 debug 2022-04-01 20:54:03 -07:00
lamp 16f4b7eaf9 fix 2022-04-01 20:53:25 -07:00
lamp 940d3f6c30 show world in 2022-04-01 20:37:44 -07:00
lamp 4252a2f060 fucking env variables 2022-03-31 18:38:00 -07:00
lamp f602638aae fix 2022-03-31 18:11:15 -07:00
lamp c9c45d17e7 need defer 2022-03-31 18:01:55 -07:00
lamp bf27b6519a fix 2022-03-31 17:59:22 -07:00
lamp 085b51a95d fix 2022-03-31 17:57:06 -07:00
lamp fc41f8ad2f a2 2022-03-31 17:55:55 -07:00
lamp d6d05f6a72 vrchat function only 2022-03-31 17:42:15 -07:00
6 changed files with 267 additions and 49 deletions
+1 -1
View File
@@ -8,5 +8,5 @@ var client = module.exports = new Discord.Client({
client.login(config.token).then(async () => { client.login(config.token).then(async () => {
console.log("ready"); console.log("ready");
(await client.channels.fetch(config.bot_channel))?.send('a'); (await client.channels.fetch(config.bot_channel))?.send('a2');
}); });
+1 -30
View File
@@ -123,7 +123,7 @@ var commands = module.exports = [
exec: i => commands.find(x => x.name == "steal").exec(i) exec: i => commands.find(x => x.name == "steal").exec(i)
}, },
{ {
name: "setserverbanner", name: "setbanner",
description: "Set the server banner image", description: "Set the server banner image",
options: [ options: [
{ {
@@ -150,35 +150,6 @@ var commands = module.exports = [
await i.reply(error.message); await i.reply(error.message);
} }
} }
},
{
name: "setservericon",
description: "Change the server icon",
options: [
{
name: "url",
description: "HTTP(S) URL to an image",
type: "STRING"
}
],
exec: async i => {
var url = i.options.getString("url");
try {
if (!url) {
await i.guild.setIcon(null);
await i.reply("cleared the server icon");
} else {
if (/^https?:\/\//i.test(url)) {
await i.guild.setIcon(url);
await i.reply(url);
} else {
await i.reply("http image url only!");
}
}
} catch (error) {
await i.reply(error.message);
}
}
} }
]; ];
+2 -16
View File
@@ -1,20 +1,6 @@
process.title = "lamp discord bot";
process.on("unhandledRejection", error => { process.on("unhandledRejection", error => {
console.error("Unhandled Rejection:\n" + error.stack); console.error("Unhandled Rejection:\n" + error.stack);
}); });
require("./util"); // global variables set in here require("dotenv").config();
require("./client"); require("./vrchat");
require("./discord-misc");
require('./eval-exec');
require('./colors');
require('./www');
require('./pinboard');
require('./pixiv-embedder');
require('./translate2');
require('./world-clock');
require('./buttonthing');
require("./activitytracker");
require("./vocabularygame");
require("./pixiv-subscribe");
require("./count-cmd");
+162 -1
View File
@@ -8,12 +8,14 @@
"@discordjs/voice": "^0.7.5", "@discordjs/voice": "^0.7.5",
"deepl": "^1.0.12", "deepl": "^1.0.12",
"discord.js": "^13.6.0", "discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"express": "^4.17.1", "express": "^4.17.1",
"fast-average-color-node": "^1.0.3", "fast-average-color-node": "^1.0.3",
"kuroshiro": "^1.2.0", "kuroshiro": "^1.2.0",
"kuroshiro-analyzer-kuromoji": "^1.1.0", "kuroshiro-analyzer-kuromoji": "^1.1.0",
"libsodium-wrappers": "^0.7.9", "libsodium-wrappers": "^0.7.9",
"node-fetch": "^2.6.1" "node-fetch": "^2.6.1",
"vrchat": "^1.6.9"
} }
}, },
"node_modules/@babel/runtime": { "node_modules/@babel/runtime": {
@@ -143,6 +145,11 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/@types/tough-cookie": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.1.tgz",
"integrity": "sha512-Y0K95ThC3esLEYD6ZuqNek29lNX2EM1qxV8y2FTLUB0ff5wWrk7az+mLrnNFUnaXcgKye22+sFBRXOgpPILZNg=="
},
"node_modules/@types/ws": { "node_modules/@types/ws": {
"version": "8.2.2", "version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
@@ -227,6 +234,23 @@
"follow-redirects": "^1.14.0" "follow-redirects": "^1.14.0"
} }
}, },
"node_modules/axios-cookiejar-support": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/axios-cookiejar-support/-/axios-cookiejar-support-1.0.1.tgz",
"integrity": "sha512-IZJxnAJ99XxiLqNeMOqrPbfR7fRyIfaoSLdPUf4AMQEGkH8URs0ghJK/xtqBsD+KsSr3pKl4DEQjCn834pHMig==",
"dependencies": {
"is-redirect": "^1.0.0",
"pify": "^5.0.0"
},
"engines": {
"node": ">= 10.0.0"
},
"peerDependencies": {
"@types/tough-cookie": ">=2.3.3",
"axios": ">=0.16.2",
"tough-cookie": ">=2.3.3"
}
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -471,6 +495,14 @@
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/dotenv": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
"integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==",
"engines": {
"node": ">=12"
}
},
"node_modules/doublearray": { "node_modules/doublearray": {
"version": "0.0.2", "version": "0.0.2",
"resolved": "https://registry.npmjs.org/doublearray/-/doublearray-0.0.2.tgz", "resolved": "https://registry.npmjs.org/doublearray/-/doublearray-0.0.2.tgz",
@@ -784,6 +816,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-redirect": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz",
"integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/isarray": { "node_modules/isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@@ -1083,6 +1123,17 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}, },
"node_modules/pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/prism-media": { "node_modules/prism-media": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz", "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz",
@@ -1125,6 +1176,19 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/psl": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
"integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
},
"node_modules/punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"engines": {
"node": ">=6"
}
},
"node_modules/qs": { "node_modules/qs": {
"version": "6.7.0", "version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
@@ -1389,6 +1453,19 @@
"node": ">=0.6" "node": ">=0.6"
} }
}, },
"node_modules/tough-cookie": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
"dependencies": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
},
"engines": {
"node": ">=6"
}
},
"node_modules/ts-mixer": { "node_modules/ts-mixer": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
@@ -1411,6 +1488,14 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/unpipe": { "node_modules/unpipe": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -1440,6 +1525,17 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/vrchat": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/vrchat/-/vrchat-1.6.9.tgz",
"integrity": "sha512-eV3EzHtObBGIzb5tEOP6vqeZsGIlMLXybO2CwpkSDvGra2ORIoh5hYnUq9JeMnAsmwF/xMpPHrb5yg5ZPDhAoA==",
"dependencies": {
"@types/tough-cookie": "^4.0.1",
"axios": "^0.21.4",
"axios-cookiejar-support": "^1.0.1",
"tough-cookie": "^4.0.0"
}
},
"node_modules/wide-align": { "node_modules/wide-align": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
@@ -1593,6 +1689,11 @@
} }
} }
}, },
"@types/tough-cookie": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.1.tgz",
"integrity": "sha512-Y0K95ThC3esLEYD6ZuqNek29lNX2EM1qxV8y2FTLUB0ff5wWrk7az+mLrnNFUnaXcgKye22+sFBRXOgpPILZNg=="
},
"@types/ws": { "@types/ws": {
"version": "8.2.2", "version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
@@ -1668,6 +1769,15 @@
"follow-redirects": "^1.14.0" "follow-redirects": "^1.14.0"
} }
}, },
"axios-cookiejar-support": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/axios-cookiejar-support/-/axios-cookiejar-support-1.0.1.tgz",
"integrity": "sha512-IZJxnAJ99XxiLqNeMOqrPbfR7fRyIfaoSLdPUf4AMQEGkH8URs0ghJK/xtqBsD+KsSr3pKl4DEQjCn834pHMig==",
"requires": {
"is-redirect": "^1.0.0",
"pify": "^5.0.0"
}
},
"balanced-match": { "balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -1856,6 +1966,11 @@
"ws": "^8.4.0" "ws": "^8.4.0"
} }
}, },
"dotenv": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
"integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q=="
},
"doublearray": { "doublearray": {
"version": "0.0.2", "version": "0.0.2",
"resolved": "https://registry.npmjs.org/doublearray/-/doublearray-0.0.2.tgz", "resolved": "https://registry.npmjs.org/doublearray/-/doublearray-0.0.2.tgz",
@@ -2110,6 +2225,11 @@
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
}, },
"is-redirect": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz",
"integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ="
},
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@@ -2330,6 +2450,11 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}, },
"pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA=="
},
"prism-media": { "prism-media": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz", "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz",
@@ -2350,6 +2475,16 @@
"ipaddr.js": "1.9.1" "ipaddr.js": "1.9.1"
} }
}, },
"psl": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
"integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"qs": { "qs": {
"version": "6.7.0", "version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
@@ -2558,6 +2693,16 @@
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
}, },
"tough-cookie": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
"requires": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
}
},
"ts-mixer": { "ts-mixer": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
@@ -2577,6 +2722,11 @@
"mime-types": "~2.1.24" "mime-types": "~2.1.24"
} }
}, },
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"unpipe": { "unpipe": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -2597,6 +2747,17 @@
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
}, },
"vrchat": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/vrchat/-/vrchat-1.6.9.tgz",
"integrity": "sha512-eV3EzHtObBGIzb5tEOP6vqeZsGIlMLXybO2CwpkSDvGra2ORIoh5hYnUq9JeMnAsmwF/xMpPHrb5yg5ZPDhAoA==",
"requires": {
"@types/tough-cookie": "^4.0.1",
"axios": "^0.21.4",
"axios-cookiejar-support": "^1.0.1",
"tough-cookie": "^4.0.0"
}
},
"wide-align": { "wide-align": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
+3 -1
View File
@@ -3,11 +3,13 @@
"@discordjs/voice": "^0.7.5", "@discordjs/voice": "^0.7.5",
"deepl": "^1.0.12", "deepl": "^1.0.12",
"discord.js": "^13.6.0", "discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"express": "^4.17.1", "express": "^4.17.1",
"fast-average-color-node": "^1.0.3", "fast-average-color-node": "^1.0.3",
"kuroshiro": "^1.2.0", "kuroshiro": "^1.2.0",
"kuroshiro-analyzer-kuromoji": "^1.1.0", "kuroshiro-analyzer-kuromoji": "^1.1.0",
"libsodium-wrappers": "^0.7.9", "libsodium-wrappers": "^0.7.9",
"node-fetch": "^2.6.1" "node-fetch": "^2.6.1",
"vrchat": "^1.6.9"
} }
} }
+98
View File
@@ -0,0 +1,98 @@
var vrchat = require("vrchat");
var client = require("./client");
var config = require("./config");
var fs = require("fs");
var configuration = new vrchat.Configuration(config.vrchat_configuration);
var authenticationApi = new vrchat.AuthenticationApi(configuration);
authenticationApi.getCurrentUser().then(console.log);
var usersApi = new vrchat.UsersApi(configuration);
var worldsApi = new vrchat.WorldsApi(configuration);
var status2icon = {
"join me": '🔵',
"active": '🟢',
"ask me": '🟠',
"busy": '🔴',
"offline": '⚫'
}
try {
var vrcul = JSON.parse(fs.readFileSync("data/vrcul.json"), "utf8");
} catch(error) {
var vrcul = [];
}
async function updateUserStatuses() {
for (let x of vrcul) {
try {
let user = (await usersApi.getUser(x.userId)).data;
let status_icon = user.state == "online" ? status2icon[user.status] : '⚫';
let nn = `${status_icon} ${user.displayName}`;
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) { //todo debug
await belowChannel.setName(bcn);
} else {
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.stack);
}
}
}
module.exports.interval = setInterval(updateUserStatuses, 1000*60*5);
client.on("interactionCreate", async i => {
if (i.commandName == "addvru") {
try {
await i.deferReply();
let u = i.options.getString("user");
let user = (await usersApi[u.startsWith("usr_") ? 'getUser' : 'getUserByName'](u)).data;
let status_icon = user.state == "online" ? status2icon[user.status] : '⚫';
let nn = `${status_icon} ${user.displayName}`;
let channel = await client.channels.resolve(config.vrchat_status_category).createChannel(nn, {type: "GUILD_VOICE"});
vrcul.push({channel: channel.id, userId: user.id});
fs.writeFileSync("data/vrcul.json", JSON.stringify(vrcul));
await i.editReply(channel.toString());
} catch (error) {
i.reply(error.message);
}
}
});
var worldnamecache = {};
async function getWorldNameForId(worldId) {
if (worldId == "private") return "Private World";
return worldnamecache[worldId] = worldnamecache[worldId] || (await worldsApi.getWorld(worldId)).data.name;
}