113 lines
3.1 KiB
JavaScript
Executable File
113 lines
3.1 KiB
JavaScript
Executable File
const db = require("quick.db");
|
|
const Servers = new db.table("servers");
|
|
const Users = new db.table("users");
|
|
const { prefixes } = require("../../config");
|
|
const chalk = require("chalk");
|
|
const e = require("node-emoji");
|
|
|
|
const DatabaseDefaults = {
|
|
user: {
|
|
id: null,
|
|
blacklist: {
|
|
state: false,
|
|
replied: false,
|
|
reason: undefined
|
|
}
|
|
},
|
|
server: {
|
|
prefix: prefixes,
|
|
SourceFynnder: false,
|
|
Shortlinks: false,
|
|
embeds: true,
|
|
rp_text: true,
|
|
default_yiff: "gay"
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
defaults: DatabaseDefaults,
|
|
setupServer: async function(ctx) {
|
|
ctx.utils.log.servers.setup(ctx.guild);
|
|
await Servers.set(ctx.guild.id, DatabaseDefaults.server);
|
|
ctx.utils.log.servers.fin(ctx.guild);
|
|
return;
|
|
},
|
|
prefix: {
|
|
add: async function(ctx) {
|
|
let Prefixes = [];
|
|
let New;
|
|
Prefixes = await Servers.get(ctx.guild.id).prefix;
|
|
|
|
if (Prefixes.includes(ctx.args.join(" ")))
|
|
throw new Error("Prefix already in Database");
|
|
else {
|
|
New = await Servers.push(`${ctx.guild.id}.prefix`, ctx.args.join(" "));
|
|
}
|
|
return New;
|
|
},
|
|
remove: async function(ctx) {
|
|
if (require("../../config").prefixes.includes(ctx.args.join(" "))) {
|
|
throw new Error("You cannot remove the Default Prefix(es)");
|
|
}
|
|
|
|
let Prefixes = Servers.get(`${ctx.guild.id}.prefix`);
|
|
let New;
|
|
|
|
for (let i in Prefixes) {
|
|
console.log(
|
|
`[${i}] [${Prefixes.toString().replace(
|
|
Prefixes[i],
|
|
chalk.red(Prefixes[i])
|
|
)}]`
|
|
);
|
|
if (Prefixes[i] === ctx.args.join(" ")) {
|
|
New = Prefixes.slice(i, 1);
|
|
console.log(Prefixes.slice(i, 1));
|
|
console.log(New);
|
|
i--;
|
|
return console.log("Found it");
|
|
}
|
|
}
|
|
//return New;
|
|
}
|
|
},
|
|
toggle: {
|
|
SourceFynnder: async function(ctx) {
|
|
let Server = await Servers.get(ctx.guild.id);
|
|
Server.SourceFynnder
|
|
? console.log(
|
|
`${chalk.green("✔")} Set ${chalk.blue(
|
|
"SourceFynnder"
|
|
)} in ${chalk.magenta(ctx.guild.id)} to ${chalk.red("false")} `
|
|
)
|
|
: console.log(
|
|
`${chalk.green("✔")} Set ${chalk.blue(
|
|
"SourceFynnder"
|
|
)} in ${chalk.magenta(ctx.guild.id)} to ${chalk.green("true")} `
|
|
);
|
|
|
|
Server.SourceFynnder
|
|
? await Servers.set(`${ctx.guild.id}.SourceFynnder`, false)
|
|
: await Servers.set(`${ctx.guild.id}.SourceFynnder`, true);
|
|
},
|
|
Shortlinks: async function(ctx) {
|
|
let Server = await Servers.get(ctx.guild.id);
|
|
Server.Shortlinks
|
|
? console.log(
|
|
`${chalk.green("✔")} Set ${chalk.blue(
|
|
"Shortlinks"
|
|
)} in ${chalk.magenta(ctx.guild.id)} to ${chalk.red("false")} `
|
|
)
|
|
: console.log(
|
|
`${chalk.green("✔")} Set ${chalk.blue(
|
|
"Shortlinks"
|
|
)} in ${chalk.magenta(ctx.guild.id)} to ${chalk.green("true")} `
|
|
);
|
|
|
|
Server.Shortlinks
|
|
? await Servers.set(`${ctx.guild.id}.Shortlinks`, false)
|
|
: await Servers.set(`${ctx.guild.id}.Shortlinks`, true);
|
|
}
|
|
}
|
|
};
|