Compare commits
No commits in common. "1316460838d12ea6357f2a222a1b1a3272369e39" and "55812d642240ef0253c9116ed512a82131cafcab" have entirely different histories.
1316460838
...
55812d6422
77
client.js
77
client.js
@ -10,3 +10,80 @@ 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('a');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/* small misc stuff here */
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
client.on("guildMemberAdd", member => {
|
||||||
|
if (member.guild.id != config.guild) return;
|
||||||
|
// add role
|
||||||
|
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
|
||||||
|
// welcome message
|
||||||
|
client.channels.resolve(config.default_channel)?.send(
|
||||||
|
`Welcome ${member}. Please tell from where you entered this server and some other info about yourself in order to gain access to message history.`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
// join message
|
||||||
|
/*client.on("messageDelete", message => {
|
||||||
|
if (message.channel.id != config.default_channel) return;
|
||||||
|
if (message.type != "GUILD_MEMBER_JOIN") return;
|
||||||
|
client.channels.resolve(config.default_channel)?.send(
|
||||||
|
`sussy baka ${message.author} deleted their join message ||(from <t:${Math.floor(message.createdAt.valueOf()/1000)}>)||`
|
||||||
|
);
|
||||||
|
});*/
|
||||||
|
client.on("guildMemberRemove", member => {
|
||||||
|
if (member.guild.id != config.guild) return;
|
||||||
|
// leave message
|
||||||
|
client.channels.resolve(config.default_channel)?.send(random([
|
||||||
|
`${member.user.username} left`,
|
||||||
|
`${member.user.username} disappeared`,
|
||||||
|
`${member.user.username.toLowerCase()} is gone`
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
client.on("messageCreate", message => {
|
||||||
|
// comment thread on announcements
|
||||||
|
message.channel.id == config.announcement_channel && message.startThread({name: "Comments"});
|
||||||
|
// stupid m bot
|
||||||
|
message.author.id == "732072478519722096" && message.content.endsWith("is bad letter m is much better") && message.delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// add reactions to video and audio
|
||||||
|
{
|
||||||
|
let a = async m => {
|
||||||
|
if (m.guild?.id != config.guild) return;
|
||||||
|
if ((m.embeds.some(e => e.type == "video") || m.attachments.some(a => a.contentType?.startsWith('video'))) && !m.g) {
|
||||||
|
m.g = true;
|
||||||
|
m.react(config.mi_emoji);
|
||||||
|
}
|
||||||
|
if (m.attachments.some(a => a.contentType?.startsWith('audio')) && !m.d) {
|
||||||
|
m.d = true;
|
||||||
|
m.react(config.ki_emoji);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
client.on("messageCreate", a);
|
||||||
|
client.on("messageUpdate", (r, q) => a(q));
|
||||||
|
}
|
||||||
|
|
||||||
|
// thing to access archived channels
|
||||||
|
client.on("voiceStateUpdate", (oldState, newState) => {
|
||||||
|
if (newState.guild.id != config.guild) return;
|
||||||
|
if (oldState.channelId != config.archive_portal_voice_channel && newState.channelId == config.archive_portal_voice_channel) {
|
||||||
|
// join
|
||||||
|
newState.member?.roles.add(config.view_archived_channels_role);
|
||||||
|
} else if (oldState.channelId == config.archive_portal_voice_channel && newState.channelId != config.archive_portal_voice_channel) {
|
||||||
|
// leave
|
||||||
|
newState.member?.roles.remove(config.view_archived_channels_role);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// save deleted emojis
|
||||||
|
client.on("emojiDelete", emoji => {
|
||||||
|
client.channels.resolve(config.bot_channel)?.send({
|
||||||
|
content: "emoji deleted",
|
||||||
|
files: [{attachment: emoji.url, name: `${emoji.name}.${emoji.url.split('.').pop()}`}]
|
||||||
|
});
|
||||||
|
});
|
@ -1,76 +0,0 @@
|
|||||||
var client = require("./client.js");
|
|
||||||
var config = require("./config");
|
|
||||||
|
|
||||||
|
|
||||||
client.on("guildMemberAdd", member => {
|
|
||||||
if (member.guild.id != config.guild) return;
|
|
||||||
// add role
|
|
||||||
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
|
|
||||||
// welcome message
|
|
||||||
client.channels.resolve(config.default_channel)?.send(
|
|
||||||
`Welcome ${member}. Please tell from where you entered this server and some other info about yourself in order to gain access to message history.`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
// join message
|
|
||||||
/*client.on("messageDelete", message => {
|
|
||||||
if (message.channel.id != config.default_channel) return;
|
|
||||||
if (message.type != "GUILD_MEMBER_JOIN") return;
|
|
||||||
client.channels.resolve(config.default_channel)?.send(
|
|
||||||
`sussy baka ${message.author} deleted their join message ||(from <t:${Math.floor(message.createdAt.valueOf()/1000)}>)||`
|
|
||||||
);
|
|
||||||
});*/
|
|
||||||
client.on("guildMemberRemove", member => {
|
|
||||||
if (member.guild.id != config.guild) return;
|
|
||||||
// leave message
|
|
||||||
client.channels.resolve(config.default_channel)?.send(random([
|
|
||||||
`${member.user.username} left`,
|
|
||||||
`${member.user.username} disappeared`,
|
|
||||||
`${member.user.username.toLowerCase()} is gone`
|
|
||||||
]));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
client.on("messageCreate", message => {
|
|
||||||
// comment thread on announcements
|
|
||||||
message.channel.id == config.announcement_channel && message.startThread({name: "Comments"});
|
|
||||||
// stupid m bot
|
|
||||||
message.author.id == "732072478519722096" && message.content.endsWith("is bad letter m is much better") && message.delete();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// add reactions to video and audio
|
|
||||||
{
|
|
||||||
let a = async m => {
|
|
||||||
if (m.guild?.id != config.guild) return;
|
|
||||||
if ((m.embeds.some(e => e.type == "video") || m.attachments.some(a => a.contentType?.startsWith('video'))) && !m.g) {
|
|
||||||
m.g = true;
|
|
||||||
m.react(config.mi_emoji);
|
|
||||||
}
|
|
||||||
if (m.attachments.some(a => a.contentType?.startsWith('audio')) && !m.d) {
|
|
||||||
m.d = true;
|
|
||||||
m.react(config.ki_emoji);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client.on("messageCreate", a);
|
|
||||||
client.on("messageUpdate", (r, q) => a(q));
|
|
||||||
}
|
|
||||||
|
|
||||||
// thing to access archived channels
|
|
||||||
client.on("voiceStateUpdate", (oldState, newState) => {
|
|
||||||
if (newState.guild.id != config.guild) return;
|
|
||||||
if (oldState.channelId != config.archive_portal_voice_channel && newState.channelId == config.archive_portal_voice_channel) {
|
|
||||||
// join
|
|
||||||
newState.member?.roles.add(config.view_archived_channels_role);
|
|
||||||
} else if (oldState.channelId == config.archive_portal_voice_channel && newState.channelId != config.archive_portal_voice_channel) {
|
|
||||||
// leave
|
|
||||||
newState.member?.roles.remove(config.view_archived_channels_role);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// save deleted emojis
|
|
||||||
client.on("emojiDelete", emoji => {
|
|
||||||
client.channels.resolve(config.bot_channel)?.send({
|
|
||||||
content: "emoji deleted",
|
|
||||||
files: [{attachment: emoji.url, name: `${emoji.name}.${emoji.url.split('.').pop()}`}]
|
|
||||||
});
|
|
||||||
});
|
|
1
index.js
1
index.js
@ -5,7 +5,6 @@ process.on("unhandledRejection", error => {
|
|||||||
|
|
||||||
require("./util"); // global variables set in here
|
require("./util"); // global variables set in here
|
||||||
require("./client");
|
require("./client");
|
||||||
require("./discord-misc");
|
|
||||||
require('./eval-exec');
|
require('./eval-exec');
|
||||||
require('./colors');
|
require('./colors');
|
||||||
require('./www');
|
require('./www');
|
||||||
|
62
vrchat.js
62
vrchat.js
@ -1,6 +1,47 @@
|
|||||||
|
var vrchat = require("vrchat");
|
||||||
|
var client = require("./client");
|
||||||
|
var config = require("./config");
|
||||||
var commands = require("./commands");
|
var commands = require("./commands");
|
||||||
|
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 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 {channel, userId} of vrcul) {
|
||||||
|
try {
|
||||||
|
channel = client.channels.resolve(channel);
|
||||||
|
let user = await usersApi.getUser(userId);
|
||||||
|
let status_icon = user.state == "online" ? status2icon(user.status) : '⚫';
|
||||||
|
let nn = `${status_icon} ${user.displayName}`;
|
||||||
|
if (nn != channel.name)
|
||||||
|
await channel.setName(nn);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("vrcus", error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.interval = setInterval(updateUserStatuses, 1000*60*5);
|
||||||
|
|
||||||
commands.push({
|
commands.push({
|
||||||
name: "addvru",
|
name: "addvru",
|
||||||
description: "Add VRChat user to status monitor",
|
description: "Add VRChat user to status monitor",
|
||||||
@ -11,5 +52,20 @@ commands.push({
|
|||||||
type: "STRING",
|
type: "STRING",
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
exec: async i => {
|
||||||
|
try {
|
||||||
|
let u = i.options.getString("user");
|
||||||
|
let user = await usersApi[u.startsWith("usr_") ? 'getUser' : 'getUserByName'](u);
|
||||||
|
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);
|
||||||
|
vrcul.push({channel: channel.id, userId: user.id});
|
||||||
|
fs.writeFileSync("data/vrcul.json", JSON.stringify(vrcul));
|
||||||
|
await i.reply(channel.toString());
|
||||||
|
} catch (error) {
|
||||||
|
i.reply(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user