Compare commits

..

No commits in common. "a73f824203d7ae15db00e12d814c26ba01edeeb5" and "400e78b319fbe41cb2f9876a2f92baa15257db5f" have entirely different histories.

13 changed files with 134 additions and 80 deletions

View File

@ -7,7 +7,7 @@ client.on("guildMemberAdd", async function (member) {
}}));
});
client.on("userUpdate", async function (oldUser, user) {
var colorRole = client.guilds.resolve(config.guild)?.members.resolve(user)?.roles.color;
var colorRole = client.guilds.resolve("672956423545815040")?.members.resolve(user)?.roles.color;
if (!colorRole) return;
if (oldUser.username != user.username) await colorRole.setName(user.username);
if (oldUser.avatar != user.avatar) {

View File

@ -1,44 +0,0 @@
client.on("message", async function (message) {
let match = message.content.match(/^!(.*?)(?: (.*))?$/i);
if (!match) return;
let [content, cmd, query] = match;
let say = message.channel.send.bind(message.channel);
switch (cmd) {
case "ping": return void say("pong");
}
if (!message.member?.roles.cache.has(config.admin_role)) return;
if (message.content.startsWith("!>")) {
with (message) {
try {
var x = await eval(message.content.substr(2).trim());
} catch(e) {
var x = e.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:'```'}});
}
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}});
});
});
}
});

27
commands/eval.js Normal file
View File

@ -0,0 +1,27 @@
module.exports = class extends Akairo.Command {
constructor() {
super("eval", {
aliases: ["eval", ">"],
ownerOnly: true,
args: [{id:'code',match:'content'}]
})
}
exec (message, args) {
return exec(message, args)
}
}
async function exec (message, args) {
with (message) {
try {
var x = await eval(args.code)
} catch(e) {
var x = e.message
}
}
if (typeof x == "undefined") return void await message.react('707729833601531935');
let t = typeof x == 'string' ? 'txt' : 'js';
if (typeof x != 'string' && typeof x != "function") x = require('util').inspect(x, {depth: 1})
await message.channel.send(`\`\`\`${t}\n${x}\`\`\``, {split:{maxLength:2000,prepend:`\`\`\`${t}\n`,append:'```'}})
}

22
commands/exec.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = class extends Akairo.Command {
constructor() {
super("exec", {
aliases: ["exec", "$"],
ownerOnly: true,
args: [{id:'command',match:'content'}]
})
}
exec (message, args) {
var cp = require("child_process").spawn("bash", ["-c", args.command]);
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}})
});
});
}
}

15
commands/ping.js Normal file
View File

@ -0,0 +1,15 @@
const { Command } = require('discord-akairo');
class PingCommand extends Command {
constructor() {
super('ping', {
aliases: ['ping']
});
}
exec(message) {
return message.reply('Pong!');
}
}
module.exports = PingCommand;

View File

@ -1,13 +0,0 @@
module.exports = {
token: process.env.TOKEN,
guild: "672956423545815040",
admin_role: "776899554603565116",
human_role: "672956630962274306",
bot_role: "673671040010027034",
eval_undefined_emoji: "707729833601531935",
archive_channel: "802280618636869663",
porn_channel: "835734868427669574",
avatar_cache_dir: "/srv/www/ldb/avatars/",
avatar_cache_url: "https://ldb.owo69.me/avatars/",
}

11
listeners/rolesort.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = class extends Akairo.Listener {
constructor() {
super("rolesort", {
emitter: "client",
event: "guildMemberAdd"
})
}
async exec (member) {
await member.roles.add(member.user.bot ? "673671040010027034" : "672956630962274306")
}
}

28
main.js
View File

@ -1,17 +1,25 @@
global.config = require("./config");
global.Discord = require("discord.js");
global.Discord = require("discord.js")
global.Akairo = require("discord-akairo")
global.client = new Discord.Client({
global.client = new Akairo.AkairoClient({
ownerID: ["330499035419115522", "707359017252683896"]
},{
disableMentions: "everyone",
partials: ['MESSAGE','REACTION'],
fetchAllMembers: true
});
client.login(config.token).then(() => console.log("ready"));
})
client.login(process.env.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)
});
client.commandHandler = new Akairo.CommandHandler(client, {
directory: "commands"
})
client.commandHandler.loadAll()
client.listenerHandler = new Akairo.ListenerHandler(client, {
directory: "listeners"
})
client.commandHandler.useListenerHandler(this.listenerHandler)
client.listenerHandler.loadAll()
require('./commands.js');
// fuck akairo
require('./colors.js');
require('./pinboard.js');
require('./pinboard.js');

16
nginx.conf Normal file
View File

@ -0,0 +1,16 @@
server {
server_name ldb.owo69.me;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/owo69.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/owo69.me/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /srv/www/ldb/;
location / {
autoindex on;
try_files $uri $uri/ =404;
}
}

24
package-lock.json generated
View File

@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
"discord-akairo": "^8.1.0",
"discord.js": "^12.5.3",
"fast-average-color-node": "^1.0.3"
}
@ -221,11 +222,15 @@
"node": ">=0.10"
}
},
"node_modules/discord-akairo": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/discord-akairo/-/discord-akairo-8.1.0.tgz",
"integrity": "sha512-INWYmHo6NgyYx1ZKGSCmgznVfvkXpWGj4fGCGjO8IPkZ06Bidb9YKr4rXy2lwG0kprCjvqY0qbbhcw6N050abQ=="
},
"node_modules/discord.js": {
"version": "12.5.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz",
"integrity": "sha512-D3nkOa/pCkNyn6jLZnAiJApw2N9XrIsXUAdThf01i7yrEuqUmDGc7/CexVWwEcgbQR97XQ+mcnqJpmJ/92B4Aw==",
"deprecated": "no longer supported",
"dependencies": {
"@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1",
@ -702,9 +707,9 @@
}
},
"node_modules/tar": {
"version": "6.1.8",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.8.tgz",
"integrity": "sha512-sb9b0cp855NbkMJcskdSYA7b11Q8JsX4qe4pyUAfHp+Y6jBjJeek2ZVlwEfWayshEIwlIzXx0Fain3QG9JPm2A==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz",
"integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==",
"dependencies": {
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",
@ -931,6 +936,11 @@
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
},
"discord-akairo": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/discord-akairo/-/discord-akairo-8.1.0.tgz",
"integrity": "sha512-INWYmHo6NgyYx1ZKGSCmgznVfvkXpWGj4fGCGjO8IPkZ06Bidb9YKr4rXy2lwG0kprCjvqY0qbbhcw6N050abQ=="
},
"discord.js": {
"version": "12.5.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz",
@ -1278,9 +1288,9 @@
}
},
"tar": {
"version": "6.1.8",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.8.tgz",
"integrity": "sha512-sb9b0cp855NbkMJcskdSYA7b11Q8JsX4qe4pyUAfHp+Y6jBjJeek2ZVlwEfWayshEIwlIzXx0Fain3QG9JPm2A==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz",
"integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==",
"requires": {
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"discord-akairo": "^8.1.0",
"discord.js": "^12.5.3",
"fast-average-color-node": "^1.0.3"
}

View File

@ -3,11 +3,11 @@ var fetch = require("node-fetch");
client.on("messageReactionAdd", async (reaction, user) => {
if (reaction.emoji.name == '📍' || reaction.emoji.name == '📌') {
if (!reaction.message.guild) return;
if (reaction.message.channel.id == config.archive_channel) return;
if (reaction.message.channel.id == '802280618636869663') return;
if (reaction.message['has been "pinned"'] || reaction.count > 1) return;
reaction.message['has been "pinned"'] = true;
if (reaction.message.channel.id == config.porn_channel) {
if (reaction.message.channel.id == "835734868427669574") {
try {
await reaction.message.pin();
} catch (e) {
@ -29,7 +29,7 @@ client.on("messageReactionAdd", async (reaction, user) => {
var avatarURL = reaction.message.author.avatarURL({dynamic: true});
if (avatarURL) {
let afn = avatarURL.split('/').pop();
let lapath = config.avatar_cache_dir + afn;
let lapath = `/srv/www/ldb/avatars/${afn}`;
if (!fs.existsSync(lapath)) {
try {
(await fetch(avatarURL)).body.pipe(fs.createWriteStream(lapath));
@ -37,7 +37,7 @@ client.on("messageReactionAdd", async (reaction, user) => {
console.error("avatar download", error.message);
}
}
avatarURL = config.avatar_cache_url + afn;
avatarURL = `https://ldb.owo69.me/avatars/${afn}`;
} else avatarURL = reaction.message.author.defaultAvatarURL;
let imageCandidate = reaction.message.attachments.find(a => [".png",".jpg",".jpeg",".webp",".gif"].some(e => a.url.toLowerCase().endsWith(e)));
@ -52,6 +52,6 @@ client.on("messageReactionAdd", async (reaction, user) => {
.setColor(reaction.message.member?.roles.color?.color);
let attachments = reaction.message.attachments.filter(a => !a["will be used for the image of the embed"]).map(a => `[${a.name}](${a.url})`).join('\n');
if (attachments) embed.addField("Attachments", attachments);
(await client.channels.fetch(config.archive_channel))?.send(`https://discord.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, embed);
(await client.channels.fetch('802280618636869663'))?.send(`https://discord.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, embed);
}
});

1
readme.txt Normal file
View File

@ -0,0 +1 @@
This program is hard-coded for my discord server (environment stuff such as ids are directly in src)