Compare commits

...

3 Commits

Author SHA1 Message Date
14ec1867d5 fix split 2021-08-17 21:03:59 -07:00
7ff1e84f21 add join/leave 2021-08-17 20:49:45 -07:00
083095e636 fix role create 2021-08-17 20:32:07 -07:00
5 changed files with 39 additions and 15 deletions

View File

@ -1,10 +1,10 @@
client.on("guildMemberAdd", async function (member) {
member.roles.add(await member.guild.roles.create({data:{
member.roles.add(await member.guild.roles.create({
name: member.user.username,
color: await user2color(member.user) || "#FF0000",
mentionable: true,
permissions: 0
}}));
}));
});
client.on("userUpdate", async function (oldUser, user) {
var colorRole = client.guilds.resolve(config.guild)?.members.resolve(user)?.roles.color;

View File

@ -29,21 +29,28 @@ client.on("messageCreate", async function (message) {
if (typeof x == "undefined") return void await message.react(config.eval_undefined_emoji);
let t = typeof x == 'string' ? 'txt' : 'js';
if (typeof x != 'string' && typeof x != "function") x = require('util').inspect(x, {depth: 1});
message.channel.send(`\`\`\`${t}\n${x}\`\`\``, {split:{maxLength:2000,prepend:`\`\`\`${t}\n`,append:'```'}});
let cb = `\`\`\`${t}\n${x}\`\`\``;
if (cb.length <= 2000)
message.channel.send(cb);
else
message.channel.send({files:[{
attachment: Buffer.from(x),
name: `output.${t}`
}]});
}
else if (message.content.startsWith("!$")) {
let cp = require("child_process").spawn("bash", ["-c", message.content.substr(2).trim()]);
cp.stdout.on("data", data => {
message.channel.send(data.toString(), {split:{char:'\n',length:2000}}).catch(()=>{
message.channel.send(data.toString(), {split:{char:'',length:2000}});
});
});
cp.stderr.on("data", data => {
message.channel.send(data.toString(), {split:{char:'\n',length:2000}}).catch(()=>{
message.channel.send(data.toString(), {split:{char:'',length:2000}});
});
});
function ondat(a) {
try {
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'\n',length:2000}});
} catch(x) {
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'',length:2000}});
}
split.forEach(say);
}
cp.stdout.on("data", ondat);
cp.stderr.on("data", ondat);
}
});

View File

@ -5,9 +5,9 @@ module.exports = {
human_role: "672956630962274306",
bot_role: "673671040010027034",
eval_undefined_emoji: "707729833601531935",
default_channel: "672956424162115586",
archive_channel: "802280618636869663",
porn_channel: "835734868427669574",
avatar_cache_dir: "/srv/www/ldb/avatars/",
avatar_cache_url: "https://ldb.owo69.me/avatars/",
}

18
main.js
View File

@ -1,3 +1,4 @@
require("./util.js");
global.config = require("./config");
global.Discord = require("discord.js");
@ -8,7 +9,22 @@ global.client = new Discord.Client({
client.login(config.token).then(() => console.log("ready"));
client.on("guildMemberAdd", member => {
member.guild.id == config.guild && member.roles.add(member.user.bot ? config.bot_role : config.human_role)
if (member.guild.id != config.guild) return;
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
client.channels.resolve(config.default_channel)?.send(random([
`${member.user.username} join`,
`${member.user.username} joined`,
`${member.user.username} appear`,
`${member.user.username.toLowerCase()} here`
]));
});
client.on("guildMemberRemove", member => {
if (member.guild.id != config.guild) return;
client.channels.resolve(config.default_channel)?.send(random([
`${member.user.username} left`,
`${member.user.username} disappear`,
`${member.user.username.toLowerCase()} gone`
]));
});
require('./commands.js');

1
util.js Normal file
View File

@ -0,0 +1 @@
global.random = x => x[Math.floor(Math.random() * x.length)];