mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 08:19:08 +02:00
22.0.0
This commit is contained in:
+9
-13
@@ -7,33 +7,29 @@ class XiaoCommand extends Command {
|
||||
this.ownerOnly = info.ownerOnly;
|
||||
this.nsfw = info.nsfw;
|
||||
this.clientPermissions = info.clientPermissions;
|
||||
this.allowStaff = info.allowStaff;
|
||||
this.userPermissions = info.userPermissions;
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
if (this.ownerOnly) {
|
||||
if (!this.client.isOwner(msg.author)) return 'This Command can only be used by the bot owner.';
|
||||
if (this.ownerOnly && !this.client.isOwner(msg.author)) {
|
||||
return 'This Command can only be used by the bot owner.';
|
||||
}
|
||||
if (this.nsfw) {
|
||||
if (!msg.channel.nsfw) return 'This Command can only be used in NSFW Channels.';
|
||||
if (this.nsfw && !msg.channel.nsfw) {
|
||||
return 'This Command can only be used in NSFW Channels.';
|
||||
}
|
||||
if (msg.channel.type !== 'dm') {
|
||||
if (this.clientPermissions) {
|
||||
for (const permission of this.clientPermissions) {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has(permission))
|
||||
if (!msg.channel.permissionsFor(this.client.user).has(permission)) {
|
||||
return `This Command requires the \`${permission}\` Permission.`;
|
||||
}
|
||||
}
|
||||
}
|
||||
const staffRole = msg.guild.settings.get('staffRole');
|
||||
if (staffRole && this.allowStaff) {
|
||||
if (!msg.member.roles.has(staffRole))
|
||||
return `This Command can only be used by the \`${msg.guild.roles.get(staffRole).name}\` role.`;
|
||||
}
|
||||
if (this.userPermissions && (this.allowStaff ? !msg.member.roles.has(staffRole) : true)) {
|
||||
if (this.userPermissions) {
|
||||
for (const permission of this.userPermissions) {
|
||||
if (!msg.channel.permissionsFor(msg.author).has(permission))
|
||||
if (!msg.channel.permissionsFor(msg.author).has(permission)) {
|
||||
return `You do not have the \`${permission}\` Permission.`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ const Database = require('./PostgreSQL');
|
||||
class CommandoClient extends Client {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.database = Database.db;
|
||||
|
||||
Database.start();
|
||||
|
||||
@@ -9,14 +9,14 @@ class Database {
|
||||
|
||||
static start() {
|
||||
database.authenticate()
|
||||
.then(() => console.log('[Database] Connection has been established successfully.'))
|
||||
.then(() => console.log('[Database] Synchronizing...'))
|
||||
.then(() => console.log('[DATABASE] Connection has been established successfully.'))
|
||||
.then(() => console.log('[DATABASE] Synchronizing...'))
|
||||
.then(() => database.sync()
|
||||
.then(() => console.log('[Database] Synchronizing complete!'))
|
||||
.catch(err => console.error(`[Database] Error synchronizing: ${err}`))
|
||||
.then(() => console.log('[DATABASE] Synchronizing complete!'))
|
||||
.catch(err => console.error(`[DATABASE] Error synchronizing: ${err}`))
|
||||
)
|
||||
.then(() => console.log('[Database] Ready!'))
|
||||
.catch(err => console.error(`[Database] Unable to connect: ${err}`));
|
||||
.then(() => console.log('[DATABASE] Ready!'))
|
||||
.catch(err => console.error(`[DATABASE] Unable to connect: ${err}`));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-9
@@ -2,21 +2,28 @@ const snekfetch = require('snekfetch');
|
||||
const { CARBON_KEY, DBOTS_KEY } = process.env;
|
||||
|
||||
class Stats {
|
||||
static dBots(server_count, id) {
|
||||
static dBots(count, id) {
|
||||
snekfetch
|
||||
.post(`https://bots.discord.pw/api/bots/${id}/stats`)
|
||||
.set({ Authorization: DBOTS_KEY })
|
||||
.send({ server_count })
|
||||
.then(() => console.log('[Carbon] Successfully posted to Carbon.'))
|
||||
.catch(err => console.error(`[Carbon] Failed to post to Carbon. ${err}`));
|
||||
.set({
|
||||
Authorization: DBOTS_KEY
|
||||
})
|
||||
.send({
|
||||
server_count: count
|
||||
})
|
||||
.then(() => console.log('[CARBON] Successfully posted to Carbon.'))
|
||||
.catch(err => console.error(`[CARBON] Failed to post to Carbon. ${err}`));
|
||||
}
|
||||
|
||||
static carbon(servercount) {
|
||||
static carbon(count) {
|
||||
snekfetch
|
||||
.post('https://www.carbonitex.net/discord/data/botdata.php')
|
||||
.send({ key: CARBON_KEY, servercount })
|
||||
.then(() => console.log('[DBots] Successfully posted to DBots.'))
|
||||
.catch(err => console.error(`[DBots] Failed to post to DBots. ${err}`));
|
||||
.send({
|
||||
key: CARBON_KEY,
|
||||
servercount: count
|
||||
})
|
||||
.then(() => console.log('[DBOTS] Successfully posted to Discord Bots.'))
|
||||
.catch(err => console.error(`[DBOTS] Failed to post to Discord Bots. ${err}`));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Util {
|
||||
static cleanXML(str) {
|
||||
return str
|
||||
.replace(/(<br \/>)/g, '')
|
||||
.replace(/(')/g, '\'')
|
||||
.replace(/(—)/g, '—')
|
||||
.replace(/("|")/g, '"')
|
||||
.replace(/(&)/g, '&')
|
||||
.replace(/(\[i\]|\[\/i\])/g, '*');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
Reference in New Issue
Block a user