mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 01:57:54 +02:00
Another Rewrite Type Thing
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { version } = require('../../package.json');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
module.exports = class InfoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'info',
|
||||
aliases: [
|
||||
'data',
|
||||
'information'
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'info',
|
||||
description: 'Gives some bot info for your shard. (;info)',
|
||||
examples: [';info']
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
}
|
||||
const guilds = await this.client.shard.fetchClientValues('guilds.size');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.setFooter(`©2017 dragonfire535 | Version ${version} | Created ${moment.duration(Date.now() - this.client.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago!`)
|
||||
.addField('Servers',
|
||||
`${this.client.guilds.size} / ${guilds.reduce((prev, val) => prev + val, 0)}`, true)
|
||||
.addField('Shards',
|
||||
`${this.client.options.shardCount} (${this.client.shard.id})`, true)
|
||||
.addField('Commands',
|
||||
'112', true)
|
||||
.addField('Owner',
|
||||
'dragonfire535#8081', true)
|
||||
.addField('Source Code',
|
||||
'[View Here](https://github.com/dragonfire535/xiaobot)', true)
|
||||
.addField('Memory Usage',
|
||||
`${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`, true)
|
||||
.addField('Uptime',
|
||||
moment.duration(this.client.uptime).format('d[d]h[h]m[m]s[s]'), true)
|
||||
.addField('Node Version',
|
||||
process.version, true)
|
||||
.addField('Library',
|
||||
'[discord.js](https://discord.js.org/#/)', true)
|
||||
.addField('Modules',
|
||||
'[commando](https://github.com/Gawdl3y/discord.js-commando), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)')
|
||||
.addField('APIs',
|
||||
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Yandex.Translate](https://translate.yandex.com/developers), [Wikipedia](https://en.wikipedia.org/w/api.php)');
|
||||
return message.embed(embed);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class InviteCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'invite',
|
||||
group: 'util',
|
||||
memberName: 'invite',
|
||||
description: 'Sends you an invite for the bot and an invite to my server. (;invite)',
|
||||
examples: [';invite']
|
||||
});
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
return message.say('Add me to your server with this link:\nhttps://discordapp.com/oauth2/authorize?client_id=278305350804045834&scope=bot&permissions=1345846343\nOr, come to my server with this link:\nhttps://discord.gg/fqQF8mc');
|
||||
}
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class SendDMCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'senddm',
|
||||
aliases: [
|
||||
'dm',
|
||||
'recontact'
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'senddm',
|
||||
description: 'Sends a DM to a user ID.',
|
||||
examples: [';senddm 278305350804045834 This is a DM.'],
|
||||
args: [{
|
||||
key: 'userid',
|
||||
prompt: 'What is the User ID of the user you wish to contact?',
|
||||
type: 'string',
|
||||
validate: userID => {
|
||||
if (userID.length === 18) {
|
||||
return true;
|
||||
}
|
||||
return 'Invalid ID.';
|
||||
}
|
||||
}, {
|
||||
key: 'content',
|
||||
prompt: 'What would you like the content of the message to be?',
|
||||
type: 'string'
|
||||
}]
|
||||
});
|
||||
}
|
||||
hasPermission(msg) {
|
||||
return this.client.isOwner(msg.author);
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const userID = args.userid;
|
||||
const content = args.content;
|
||||
try {
|
||||
await this.client.users.get(userID).send(content);
|
||||
return message.say('Success!');
|
||||
}
|
||||
catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -9,7 +9,7 @@ module.exports = class ServersCommand extends Command {
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'servers',
|
||||
description: 'Sends a list of all server names and IDs to the log.',
|
||||
description: 'Sends a list of all server names and IDs to the log. (;servers)',
|
||||
examples: [';servers']
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { version } = require('../../package.json');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
module.exports = class ShardInfoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'shardinfo',
|
||||
aliases: [
|
||||
'shard-info',
|
||||
'shard-data',
|
||||
'sharddata',
|
||||
'shard'
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'shardinfo',
|
||||
description: 'Gives some bot info for the Shard you specify. (;shardinfo 0)',
|
||||
examples: [';shardinfo 0'],
|
||||
args: [{
|
||||
key: 'shardID',
|
||||
prompt: 'Which Shard would you like to get data for?',
|
||||
type: 'integer'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
}
|
||||
const shardID = args.shardID;
|
||||
if (shardID > this.client.options.shardCount - 1 || shardID < 0) {
|
||||
return message.say(':x: Error! Invalid Shard!');
|
||||
}
|
||||
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
|
||||
const uptime = await this.client.shard.fetchClientValues('uptime');
|
||||
const guilds = await this.client.shard.fetchClientValues('guilds.size');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.addField('Servers',
|
||||
guilds[shardID], true)
|
||||
.addField('Shard ID',
|
||||
shardID, true)
|
||||
.addField('Memory Usage',
|
||||
`${memory[shardID]}MB`, true)
|
||||
.addField('Uptime',
|
||||
moment.duration(uptime[shardID]).format('d[d]h[h]m[m]s[s]'), true)
|
||||
.addField('Version',
|
||||
version, true)
|
||||
.addField('Node Version',
|
||||
process.version, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
module.exports = class UptimeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'uptime',
|
||||
group: 'util',
|
||||
memberName: 'uptime',
|
||||
description: 'Displays how long the bot has been active. (;uptime)',
|
||||
examples: [';uptime']
|
||||
});
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
return message.say(`I've been active on this shard for: **${moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]')}**!`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user