Compare commits

..

No commits in common. "14ec1867d5ea53c27802f0db513d4e5c01235f47" and "d147167682fd54d2005f6de8936e541db09f843e" have entirely different histories.

5 changed files with 15 additions and 39 deletions

View File

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

View File

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

View File

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

18
main.js
View File

@ -1,4 +1,3 @@
require("./util.js");
global.config = require("./config"); global.config = require("./config");
global.Discord = require("discord.js"); global.Discord = require("discord.js");
@ -9,22 +8,7 @@ global.client = new Discord.Client({
client.login(config.token).then(() => console.log("ready")); client.login(config.token).then(() => console.log("ready"));
client.on("guildMemberAdd", member => { client.on("guildMemberAdd", member => {
if (member.guild.id != config.guild) return; member.guild.id == config.guild && member.roles.add(member.user.bot ? config.bot_role : config.human_role)
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'); require('./commands.js');

View File

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