Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d04200742d | |||
| fbb082fee8 | |||
| bb80d22568 | |||
| 721435f039 | |||
| e85d88de69 | |||
| a4730289a0 | |||
| 02be479a15 | |||
| 1b2df7a1cb | |||
| 7eb01dda9d | |||
| c130ef1506 | |||
| 660234acfd | |||
| c0470e89b6 | |||
| 823c398a5a | |||
| 9b84e4ff7c | |||
| e19f11acae | |||
| 0fcd5f125c | |||
| 1316460838 |
@@ -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('a2');
|
(await client.channels.fetch(config.bot_channel))?.send('a');
|
||||||
});
|
});
|
||||||
|
|||||||
+81
-36
@@ -38,32 +38,6 @@ var commands = module.exports = [
|
|||||||
i.reply(owo);
|
i.reply(owo);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "archive",
|
|
||||||
description: "Delete a channel without actually deleting it",
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "channel",
|
|
||||||
description: "channel",
|
|
||||||
type: "CHANNEL",
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
defaultPermission: false,
|
|
||||||
permissions: [
|
|
||||||
{
|
|
||||||
id: config.admin_role,
|
|
||||||
type: "ROLE",
|
|
||||||
permission: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
exec: async i => {
|
|
||||||
let channel = i.options.getChannel("channel");
|
|
||||||
await channel.setParent(config.archive_category);
|
|
||||||
await channel.lockPermissions();
|
|
||||||
await i.reply({content: channel.toString()});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "avatar",
|
name: "avatar",
|
||||||
description: "View a user's original avatar (and save permanently as attachment)",
|
description: "View a user's original avatar (and save permanently as attachment)",
|
||||||
@@ -123,7 +97,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: "setbanner",
|
name: "setserverbanner",
|
||||||
description: "Set the server banner image",
|
description: "Set the server banner image",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@@ -150,6 +124,86 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "getemoji",
|
||||||
|
description: "Generate a URL for an emoji",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "emoji",
|
||||||
|
description: "The emoji (code) or the name of the emoji (case-sensitive)",
|
||||||
|
type: "STRING",
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "format",
|
||||||
|
description: "choose image format",
|
||||||
|
type: "STRING",
|
||||||
|
choices: [
|
||||||
|
{name: "PNG", value: "png"},
|
||||||
|
{name: "JPG", value: "jpg"},
|
||||||
|
{name: "WEBP", value: "webp"},
|
||||||
|
{name: "GIF", value: "gif"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "size",
|
||||||
|
description: "choose image size",
|
||||||
|
type: "INTEGER",
|
||||||
|
choices: "16,20,22,24,28,32,40,44,48,56,60,64,80,96,100,128".split(',').map(s => ({name: s, value: Number(s)}))
|
||||||
|
}
|
||||||
|
],
|
||||||
|
exec: i => {
|
||||||
|
var emojiname = i.options.getString("emoji");
|
||||||
|
if (emojiname.startsWith('<') && emojiname.endsWith('>')) emoji = Discord.Util.parseEmoji(emojiname);
|
||||||
|
else {
|
||||||
|
if (emojiname.startsWith(':')) emojiname = emojiname.slice(1);
|
||||||
|
if (emojiname.endsWith(':')) emojiname = emojiname.slice(-1);
|
||||||
|
var emoji = client.emojis.cache.find(e => e.name == emojiname);
|
||||||
|
if (!emoji) emoji = client.emojis.cache.find(e => e.name.toLowerCase() == emojiname.toLowerCase());
|
||||||
|
if (!emoji) return void i.reply(`could not find emoji named ${emojiname}`);
|
||||||
|
}
|
||||||
|
if (!emoji.id) return void i.reply(`invalid input`);
|
||||||
|
var qs = [];
|
||||||
|
var size = i.options.getInteger("size");
|
||||||
|
if (size) qs.push(`size=${size}`);
|
||||||
|
var format = i.options.getString("format");
|
||||||
|
if (!format) format = emoji.animated ? "gif" : "png";
|
||||||
|
if (format == "gif" && !emoji.animated) return void i.reply(`Non-animated emoji is not available as GIF.`);
|
||||||
|
if (format == "webp") qs.push(`quality=lossless`);
|
||||||
|
var url = `https://media.discordapp.net/emojis/${emoji.id}.${format}`;
|
||||||
|
if (qs.length > 0) url += '?' + qs.join('&');
|
||||||
|
i.reply(`${emoji.name}.${format}\n${url}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -162,14 +216,5 @@ client.once("ready", async () => {
|
|||||||
let guild_commands = commands.filter(x => !x.global);
|
let guild_commands = commands.filter(x => !x.global);
|
||||||
let guild = client.guilds.resolve(config.guild);
|
let guild = client.guilds.resolve(config.guild);
|
||||||
await guild.commands.set(guild_commands);
|
await guild.commands.set(guild_commands);
|
||||||
await guild.commands.permissions.set({
|
|
||||||
fullPermissions: guild_commands.map(local_command => {
|
|
||||||
let discord_command = guild.commands.cache.find(discord_command => local_command.name == discord_command.name);
|
|
||||||
return {
|
|
||||||
id: discord_command.id,
|
|
||||||
permissions: local_command.permissions || []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
await client.application.commands.set(global_commands);
|
await client.application.commands.set(global_commands);
|
||||||
});
|
});
|
||||||
@@ -8,6 +8,7 @@ module.exports = {
|
|||||||
human_role: "672956630962274306",
|
human_role: "672956630962274306",
|
||||||
bot_role: "673671040010027034",
|
bot_role: "673671040010027034",
|
||||||
inactive_role: "892869309603389500",
|
inactive_role: "892869309603389500",
|
||||||
|
verified_role: "949064806030254130",
|
||||||
view_archived_channels_role: "916056534402863125",
|
view_archived_channels_role: "916056534402863125",
|
||||||
eval_undefined_emoji: "707729833601531935",
|
eval_undefined_emoji: "707729833601531935",
|
||||||
mi_emoji: "887931046086185060",
|
mi_emoji: "887931046086185060",
|
||||||
@@ -77,5 +78,9 @@ module.exports = {
|
|||||||
vrchat_configuration: {
|
vrchat_configuration: {
|
||||||
username: process.env.VRCHAT_USERNAME,
|
username: process.env.VRCHAT_USERNAME,
|
||||||
password: process.env.VRCHAT_PASSWORD
|
password: process.env.VRCHAT_PASSWORD
|
||||||
|
},
|
||||||
|
masto: {
|
||||||
|
url: "https://mastodong.lol",
|
||||||
|
accessToken: process.env.MASTO_TOKEN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,12 @@ client.on("guildMemberAdd", member => {
|
|||||||
// add role
|
// add role
|
||||||
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
|
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
|
||||||
// welcome message
|
// welcome message
|
||||||
|
/*setTimeout(() => {
|
||||||
client.channels.resolve(config.default_channel)?.send(
|
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.`
|
`Welcome ${member}. Please tell from where you entered this server and some other info about yourself in order to gain access to message history.`
|
||||||
);
|
);
|
||||||
|
}, 3000);*/
|
||||||
|
member.roles.add(config.verified_role);
|
||||||
});
|
});
|
||||||
// join message
|
// join message
|
||||||
/*client.on("messageDelete", message => {
|
/*client.on("messageDelete", message => {
|
||||||
@@ -74,3 +77,5 @@ client.on("emojiDelete", emoji => {
|
|||||||
files: [{attachment: emoji.url, name: `${emoji.name}.${emoji.url.split('.').pop()}`}]
|
files: [{attachment: emoji.url, name: `${emoji.name}.${emoji.url.split('.').pop()}`}]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//g=setInterval(() => client.guilds.resolve(config.guild)?.setIcon(`mf/${Math.floor(Math.random()*14548)}.png`), 1800000);
|
||||||
@@ -1,6 +1,21 @@
|
|||||||
|
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 || error));
|
||||||
});
|
});
|
||||||
|
|
||||||
require("dotenv").config();
|
require("./util"); // global variables set in here
|
||||||
require("./vrchat");
|
require("./client");
|
||||||
|
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");
|
||||||
|
require("./masto");
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
var {login} = require("masto");
|
||||||
|
var config = require("./config");
|
||||||
|
var client = require("./client");
|
||||||
|
|
||||||
|
client.once("ready", async () => {
|
||||||
|
var donger = await login(config.masto);
|
||||||
|
module.exports = donger;
|
||||||
|
var stream = await donger.stream.streamUser();
|
||||||
|
stream.on("update", toot => {
|
||||||
|
console.debug("toot", toot); // testing
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Generated
+482
-187
File diff suppressed because it is too large
Load Diff
+2
-3
@@ -3,13 +3,12 @@
|
|||||||
"@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",
|
"masto": "^4.4.0",
|
||||||
"vrchat": "^1.6.9"
|
"node-fetch": "^2.6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -17,9 +17,10 @@ async function check(tag, channel) {
|
|||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
for (let i = newPosts.length - 1; i >= 0; i--) {
|
for (let i = newPosts.length - 1; i >= 0; i--) {
|
||||||
|
let url = `https://www.pixiv.net/en/artworks/${newPosts[i].id}`;
|
||||||
await embedPixiv(
|
await embedPixiv(
|
||||||
client.channels.resolve(channel),
|
client.channels.resolve(channel),
|
||||||
[`https://www.pixiv.net/en/artworks/${newPosts[i].id}`],
|
[url],
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user