mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Discord.js v14
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, embedURL } = require('../../util/Util');
|
||||
const { GITHUB_ACCESS_TOKEN } = process.env;
|
||||
@@ -31,7 +31,7 @@ module.exports = class ChangelogCommand extends Command {
|
||||
.get(`https://api.github.com/repos/${XIAO_GITHUB_REPO_USERNAME}/${XIAO_GITHUB_REPO_NAME}/commits`)
|
||||
.set({ Authorization: `token ${GITHUB_ACCESS_TOKEN}` });
|
||||
const commits = body.slice(0, 10);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`[${XIAO_GITHUB_REPO_NAME}:master] Latest 10 commits`)
|
||||
.setColor(0x7289DA)
|
||||
.setURL(`https://github.com/${XIAO_GITHUB_REPO_USERNAME}/${XIAO_GITHUB_REPO_NAME}/commits/master`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
const { promisify } = require('util');
|
||||
const exec = promisify(require('child_process').execFile);
|
||||
@@ -13,7 +13,7 @@ module.exports = class ClocCommand extends Command {
|
||||
memberName: 'cloc',
|
||||
description: 'Responds with the bot\'s code line count.',
|
||||
guarded: true,
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks]
|
||||
});
|
||||
|
||||
this.cache = null;
|
||||
@@ -21,9 +21,9 @@ module.exports = class ClocCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
const cloc = await this.cloc();
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x00AE86)
|
||||
.setFooter(`${cloc.header.cloc_url} ${cloc.header.cloc_version}`)
|
||||
.setFooter({ text: `${cloc.header.cloc_url} ${cloc.header.cloc_version}` })
|
||||
.addField(`❯ JS (${formatNumber(cloc.JavaScript.nFiles)})`, formatNumber(cloc.JavaScript.code), true)
|
||||
.addField(`❯ JSON (${formatNumber(cloc.JSON.nFiles)})`, formatNumber(cloc.JSON.code), true)
|
||||
.addField(`❯ MD (${formatNumber(cloc.Markdown.nFiles)})`, formatNumber(cloc.Markdown.code), true)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { embedURL } = require('../../util/Util');
|
||||
|
||||
module.exports = class CreditCommand extends Command {
|
||||
@@ -29,14 +29,14 @@ module.exports = class CreditCommand extends Command {
|
||||
if (!command.credit) return msg.say('This command is credited to no one. It just appeared.');
|
||||
const totalPages = Math.ceil(command.credit.length / 10);
|
||||
if (page > totalPages) return msg.say(`Page ${page} does not exist (yet).`);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${command.name} (Page ${page}/${totalPages})`)
|
||||
.setColor(0x7289DA)
|
||||
.setDescription(command.credit.slice((page - 1) * 10, page * 10).map(credit => {
|
||||
if (!credit.reasonURL) return `${embedURL(credit.name, credit.url)} (${credit.reason})`;
|
||||
return `${embedURL(credit.name, credit.url)} (${embedURL(credit.reason, credit.reasonURL)})`;
|
||||
}).join('\n'))
|
||||
.setFooter(`${command.credit.length} Total Credit${command.credit.length === 1 ? '' : 's'}`);
|
||||
.setFooter({ text: `${command.credit.length} Total Credit${command.credit.length === 1 ? '' : 's'}` });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class HelpCommand extends Command {
|
||||
@@ -26,7 +26,7 @@ module.exports = class HelpCommand extends Command {
|
||||
const embeds = [];
|
||||
for (let i = 0; i < Math.ceil(this.client.registry.groups.size / 10); i++) {
|
||||
const nsfw = msg.channel.nsfw || this.client.isOwner(msg.author);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Command List (Page ${i + 1})`)
|
||||
.setDescription(stripIndents`
|
||||
To run a command, use ${this.usage()}.
|
||||
@@ -54,7 +54,7 @@ module.exports = class HelpCommand extends Command {
|
||||
}
|
||||
const allShown = cmdCount === this.client.registry.commands.size;
|
||||
embeds[embeds.length - 1]
|
||||
.setFooter(`${this.client.registry.commands.size} Commands${allShown ? '' : ` (${cmdCount} Shown)`}`);
|
||||
.setFooter({ text: `${this.client.registry.commands.size} Commands${allShown ? '' : ` (${cmdCount} Shown)`}` });
|
||||
try {
|
||||
const msgs = [];
|
||||
for (const embed of embeds) msgs.push(await msg.direct({ embeds: [embed] }));
|
||||
@@ -64,8 +64,6 @@ module.exports = class HelpCommand extends Command {
|
||||
return msg.reply('Failed to send DM. You probably have DMs disabled.');
|
||||
}
|
||||
}
|
||||
const userPerms = command.userPermissions.length ? command.userPermissions.join(', ') : 'None';
|
||||
const clientPerms = command.clientPermissions.length ? command.clientPermissions.join(', ') : 'None';
|
||||
return msg.say(stripIndents`
|
||||
__Command **${command.name}**__${command.guildOnly ? ' (Usable only in servers)' : ''}
|
||||
${command.description}${command.details ? `\n${command.details}` : ''}
|
||||
@@ -76,8 +74,6 @@ module.exports = class HelpCommand extends Command {
|
||||
**Aliases:** ${command.aliases.join(', ') || 'None'}
|
||||
**Group:** ${command.group.name} (\`${command.groupID}:${command.memberName}\`)
|
||||
**NSFW:** ${command.nsfw ? 'Yes' : 'No'}
|
||||
**Permissions You Need:** ${userPerms}
|
||||
**Permissions I Need:** ${clientPerms}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed, version: djsVersion } = require('discord.js');
|
||||
const { EmbedBuilder, version: djsVersion, PermissionFlagsBits } = require('discord.js');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
const { formatNumber, embedURL } = require('../../util/Util');
|
||||
@@ -15,16 +15,16 @@ module.exports = class InfoCommand extends Command {
|
||||
memberName: 'info',
|
||||
description: 'Responds with detailed bot information.',
|
||||
guarded: true,
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const invite = this.client.generateInvite({ permissions: ['ADMINISTRATOR'], scopes: ['bot'] });
|
||||
const invite = this.client.generateInvite({ permissions: [PermissionFlagsBits.Administrator], scopes: ['bot'] });
|
||||
const prefix = msg.guild ? msg.guild.commandPrefix : this.client.commandPrefix;
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x00AE86)
|
||||
.setFooter(copyright.join('\n'))
|
||||
.setFooter({ text: copyright.join('\n') })
|
||||
.addField('❯ Servers', formatNumber(this.client.guilds.cache.size), true)
|
||||
.addField('❯ Commands', formatNumber(this.client.registry.commands.size), true)
|
||||
.addField('❯ Shards', formatNumber(this.client.options.shardCount), true)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const reasons = ['bug', 'feedback', 'suggestion', 'abuse'];
|
||||
const reasonColors = ['RED', 'GREEN', 'YELLOW', 'ORANGE'];
|
||||
const reasonColors = ['Red', 'Green', 'Yellow', 'Orange'];
|
||||
const displayReasons = ['🐛 Bug Report', '📬 Feedback', '❓ Suggestion', '⚠️ Abuse'];
|
||||
|
||||
module.exports = class ReportCommand extends Command {
|
||||
@@ -29,11 +29,11 @@ module.exports = class ReportCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { reason, message }) {
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(message)
|
||||
.setTitle(displayReasons[reason])
|
||||
.setAuthor(msg.author.tag)
|
||||
.setFooter(`ID: ${msg.author.id}`)
|
||||
.setAuthor({ name: msg.author.tag })
|
||||
.setFooter({ text: `ID: ${msg.author.id}` })
|
||||
.setTimestamp()
|
||||
.setColor(reasonColors[reason]);
|
||||
const channel = await this.client.fetchReportChannel();
|
||||
|
||||
Reference in New Issue
Block a user