This commit is contained in:
codepupper 2019-11-11 18:08:27 +01:00
parent 30a1644d10
commit 314c1847ed
7 changed files with 52 additions and 34 deletions

View File

@ -1,12 +1,5 @@
const express = require('express');
const {
hostname,
port,
authorization,
source,
invite,
type
} = require('../config');
const { hostname, port, authorization, source, invite, type } = require('../config');
const db = require('quick.db');
const Backend = new db.table('backend');
const chalk = require('chalk');
@ -33,9 +26,11 @@ app.set('view options', {
});
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.use(
express.urlencoded({
extended: true
})
);
app.use(helmet());
app.use(compression());
app.use(cors());
@ -52,7 +47,7 @@ app.use(
})
);
app.use('/api', require(''))
app.use('/api', require('./routes/api'));
let support = 'https://discord.gg/' + Backend.get('Info.invite');
module.exports = (client) => {
app.get('/', async (req, res) => {
@ -105,4 +100,4 @@ module.exports = (client) => {
console.log(`Listening on ${hostname}:${port}`);
}, 1000 * 3);
});
};
};

View File

@ -1,4 +1,4 @@
const { Collection } = require('discord.js');
const { Collection, MessageEmbed } = require('discord.js');
const { table } = require('quick.db');
const Servers = new table('servers');
const Users = new table('users');
@ -58,8 +58,9 @@ module.exports = {
if (cmd.nsfw && !ctx.channel.nsfw)
return ctx.send('This channel is not marked as NSFW, please mark it as such and rerun this command.');
if (cmd.developerOnly && !client.config.developers.find((dev) => msg.author.id == dev.id)) return;
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions))
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions)) {
return ctx.send(`You need \`${cmd.AuthorPermissions}\` Permission(s) to run this Command`);
}
const now = Date.now();
const timestamps = client.cooldowns.get(cmd.name);
const cooldownAmount = (cmd.cooldown || 1) * 1000;
@ -68,14 +69,16 @@ module.exports = {
const expirationTime = timestamps.get(msg.author.id) + cooldownAmount;
if (now < expirationTime) {
let CooldownEmb = new MessageEmbed();
const timeLeft = (expirationTime - now) / 1000;
return ctx.send(
CooldownEmb.setTitle(`${cmd.name} is on cooldown`).setDescription(
`\`${cmd.name}\` has a cooldown of \`${cmd.cooldown} second${cmd.cooldown > 1
? 's'
: ''}\`, wait \`${`${Math.round(timeLeft)} second${Math.round(timeLeft) > 1
: ''}\`\n Wait \`${`${Math.round(timeLeft)} second${Math.round(timeLeft) > 1
? 's'
: ''}`.replace('0 second', 'just a second longer')}\` before trying to use it again.`
);
return ctx.send(CooldownEmb);
}
} else {
timestamps.set(msg.author.id, now);

View File

@ -23,13 +23,18 @@ module.exports = class Hug extends Command {
if (ctx.msg.mentions.members.first().id === ctx.author.id)
return ctx.send(`Don't you want to hug someone other than yourself?`);
const LineFromUtils = ctx.utils.int.hug[parseInt(Math.random() * ctx.utils.int.hug.length)];
let Line = LineFromUtils.replace(/0/g, ctx.utils.format.bold(ctx.author.username)).replace(
/1/g,
ctx.utils.format.bold(ctx.msg.mentions.members.first().user.username)
);
const Server = await ctx.db.servers.get(ctx.guild.id);
let Line;
if (Server === null) {
const LineFromUtils = ctx.utils.int.hug[parseInt(Math.random() * ctx.utils.int.hug.length)];
Line = LineFromUtils.replace(/0/g, ctx.utils.format.bold(ctx.author.username)).replace(
/1/g,
ctx.utils.format.bold(ctx.msg.mentions.members.first().user.username)
);
} else {
Line = undefined;
}
let Settings;
if (Server === null) {
Settings = ctx.utils.db.defaults.server;
@ -43,11 +48,17 @@ module.exports = class Hug extends Command {
if (Settings.embeds) {
Message = new MessageEmbed()
.setColor(ctx.config.color)
.setDescription(Line)
.setImage(req)
.setFooter(`${ctx.client.user.username} - Provided by furry.bot`, ctx.client.user.avatarURL());
if (Line) {
Message.setDescription(Line);
}
} else {
Message = `${req}`;
if (Line) {
Message = `${Line}\n${req}`;
} else {
Message = `${req}`;
}
}
ctx.send(Message);
}

View File

@ -48,11 +48,17 @@ module.exports = class Kiss extends Command {
if (Settings.embeds) {
Message = new MessageEmbed()
.setColor(ctx.config.color)
.setDescription(Line)
.setImage(req)
.setFooter(`${ctx.client.user.username} - Provided by furry.bot`, ctx.client.user.avatarURL());
if (Line) {
Message.setDescription(Line);
}
} else {
Message = `${req}`;
if (Line) {
Message = `${Line}\n${req}`;
} else {
Message = `${req}`;
}
}
ctx.send(Message);
}

View File

@ -22,7 +22,8 @@ module.exports = class nKiss extends Command {
return ctx.send("Don't kiss me! Kiss someone else!");
if (ctx.msg.mentions.members.first().id === ctx.author.id)
return ctx.send(`Don't you want to kiss someone other than yourself?`);
const Server = await ctx.db.servers.get(ctx.guild.id);
let Line;
if (Server.rp_text) {
const LineFromUtils = ctx.utils.int.kiss[parseInt(Math.random() * ctx.utils.int.kiss.length)];
Line = LineFromUtils.replace(/0/g, ctx.utils.format.bold(ctx.author.username)).replace(
@ -33,7 +34,6 @@ module.exports = class nKiss extends Command {
Line = undefined;
}
const Server = await ctx.db.servers.get(ctx.guild.id);
let Settings;
if (Server === null) {
Settings = ctx.utils.db.defaults.server;

View File

@ -8,7 +8,8 @@ module.exports = class Prefix extends Command {
module: 'Settings',
cooldown: 10,
guildOnly: true,
developerOnly: false
developerOnly: false,
AuthorPermissions: [ 'MANAGE_GUILD' ]
});
}
@ -32,7 +33,7 @@ module.exports = class Prefix extends Command {
.then(async () => {
let NServer = await ctx.db.servers.get(ctx.guild.id);
PrefixEmbed.setTitle(`Prefixes for ${ctx.guild.name}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(', ') || ctx.db.defaults.server.prefix}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
ctx.send(PrefixEmbed);
})
.catch((err) => ctx.send(err));
@ -42,9 +43,11 @@ module.exports = class Prefix extends Command {
if (ctx.args === [] || ctx.args.join(' ').trim() === '') return ctx.send('No Prefix was given');
ctx.utils.db.prefix
.remove(ctx, Prefix)
.then(async (r) => {
.then(async () => {
let NServer = await ctx.db.servers.get(ctx.guild.id);
ctx.send('Current Prefixes are:\n' + NServer.prefix.join(', '));
PrefixEmbed.setTitle(`Prefixes for ${ctx.guild.name}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
ctx.send(PrefixEmbed);
})
.catch((err) => ctx.send(err));
break;

View File

@ -45,7 +45,7 @@ module.exports = {
return New;
},
remove: async function(ctx, Prefix) {
if (prefixes.includes(Prefix)) {
if (DatabaseDefaults.server.prefix.includes(Prefix)) {
throw new Error('You cannot remove the Default Prefix(es)');
}
let Prefixes = ctx.db.servers.get(ctx.guild.id).prefix;