mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Discord.js v14
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageButton, MessageActionRow } = require('discord.js');
|
||||
const { ButtonBuilder, ActionRowBuilder, ButtonStyle } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { list } = require('../../util/Util');
|
||||
@@ -37,9 +37,9 @@ module.exports = class TwentyQuestionsCommand extends Command {
|
||||
const startURL = await this.initialize(game);
|
||||
let question = await this.startGame(game, startURL);
|
||||
let win = null;
|
||||
const initialRow = new MessageActionRow().addComponents(
|
||||
new MessageButton().setCustomId('true').setLabel('Ready!').setStyle('PRIMARY'),
|
||||
new MessageButton().setCustomId('false').setLabel('Nevermind').setStyle('SECONDARY')
|
||||
const initialRow = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId('true').setLabel('Ready!').setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder().setCustomId('false').setLabel('Nevermind').setStyle(ButtonStyle.Secondary)
|
||||
);
|
||||
const gameMsg = await msg.reply({
|
||||
content: 'Welcome to 20 Questions! Think of something, and I will try to guess it.',
|
||||
@@ -61,16 +61,16 @@ module.exports = class TwentyQuestionsCommand extends Command {
|
||||
const answers = question.answers.map(answer => answer.text);
|
||||
const rowCount = Math.ceil(answers.length / 5);
|
||||
const rows = [];
|
||||
for (let i = 0; i < rowCount; i++) rows.push(new MessageActionRow());
|
||||
for (let i = 0; i < rowCount; i++) rows.push(new ActionRowBuilder());
|
||||
for (let i = 0; i < answers.length; i += 5) {
|
||||
const row = rows[Math.floor(i / 5)];
|
||||
const components = answers.slice(i, i + 5);
|
||||
for (const component of components) {
|
||||
row.addComponents(new MessageButton().setCustomId(component).setStyle('PRIMARY').setLabel(component));
|
||||
row.addComponents(new ButtonBuilder().setCustomId(component).setStyle(ButtonStyle.Primary).setLabel(component));
|
||||
}
|
||||
}
|
||||
const sRow = new MessageActionRow();
|
||||
sRow.addComponents(new MessageButton().setCustomId('end').setStyle('DANGER').setLabel('End'));
|
||||
const sRow = new ActionRowBuilder();
|
||||
sRow.addComponents(new ButtonBuilder().setCustomId('end').setStyle(ButtonStyle.Danger).setLabel('End'));
|
||||
await buttonPress.editReply({
|
||||
content: question.question,
|
||||
components: [...rows, sRow]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, PermissionFlagsBits, ButtonStyle } = require('discord.js');
|
||||
const { Aki, regions } = require('aki-api');
|
||||
|
||||
module.exports = class AkinatorCommand extends Command {
|
||||
@@ -11,7 +11,7 @@ module.exports = class AkinatorCommand extends Command {
|
||||
memberName: 'akinator',
|
||||
description: 'Think about a real or fictional character, I will try to guess who it is.',
|
||||
details: `**Regions:** ${regions.join(', ')}`,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks],
|
||||
credit: [
|
||||
{
|
||||
name: 'Akinator',
|
||||
@@ -39,9 +39,9 @@ module.exports = class AkinatorCommand extends Command {
|
||||
let guessResetNum = 0;
|
||||
let wentBack = false;
|
||||
let forceGuess = false;
|
||||
const initialRow = new MessageActionRow().addComponents(
|
||||
new MessageButton().setCustomId('true').setLabel('Ready!').setStyle('PRIMARY'),
|
||||
new MessageButton().setCustomId('false').setLabel('Nevermind').setStyle('SECONDARY')
|
||||
const initialRow = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId('true').setLabel('Ready!').setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder().setCustomId('false').setLabel('Nevermind').setStyle(ButtonStyle.Secondary)
|
||||
);
|
||||
const gameMsg = await msg.reply({
|
||||
content: 'Welcome to Akinator! Think of a character, and I will try to guess it.',
|
||||
@@ -74,15 +74,15 @@ module.exports = class AkinatorCommand extends Command {
|
||||
}
|
||||
}
|
||||
if (!aki.answers || aki.currentStep >= 79) forceGuess = true;
|
||||
const row = new MessageActionRow();
|
||||
const row = new ActionRowBuilder();
|
||||
for (const answer of aki.answers) {
|
||||
row.addComponents(new MessageButton().setCustomId(answer).setStyle('PRIMARY').setLabel(answer));
|
||||
row.addComponents(new ButtonBuilder().setCustomId(answer).setStyle(ButtonStyle.Primary).setLabel(answer));
|
||||
}
|
||||
const sRow = new MessageActionRow();
|
||||
const sRow = new ActionRowBuilder();
|
||||
if (aki.currentStep > 0) {
|
||||
sRow.addComponents(new MessageButton().setCustomId('back').setStyle('SECONDARY').setLabel('Back'));
|
||||
sRow.addComponents(new ButtonBuilder().setCustomId('back').setStyle(ButtonStyle.Secondary).setLabel('Back'));
|
||||
}
|
||||
sRow.addComponents(new MessageButton().setCustomId('end').setStyle('DANGER').setLabel('End'));
|
||||
sRow.addComponents(new ButtonBuilder().setCustomId('end').setStyle(ButtonStyle.Danger).setLabel('End'));
|
||||
await buttonPress.editReply({
|
||||
content: `**${aki.currentStep + 1}.** ${aki.question} (${Math.round(Number.parseInt(aki.progress, 10))}%)`,
|
||||
components: [row, sRow],
|
||||
@@ -120,15 +120,15 @@ module.exports = class AkinatorCommand extends Command {
|
||||
break;
|
||||
}
|
||||
guessBlacklist.push(guess.id);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0xF78B26)
|
||||
.setTitle(`I'm ${Math.round(guess.proba * 100)}% sure it's...`)
|
||||
.setDescription(`${guess.name}${guess.description ? `\n_${guess.description}_` : ''}`)
|
||||
.setThumbnail(guess.absolute_picture_path || null)
|
||||
.setFooter(forceGuess ? 'Final Guess' : `Guess ${timesGuessed}`);
|
||||
const guessRow = new MessageActionRow().addComponents(
|
||||
new MessageButton().setCustomId('true').setLabel('Yes').setStyle('SUCCESS'),
|
||||
new MessageButton().setCustomId('false').setLabel('No').setStyle('DANGER')
|
||||
.setFooter({ text: forceGuess ? 'Final Guess' : `Guess ${timesGuessed}` });
|
||||
const guessRow = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId('true').setLabel('Yes').setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder().setCustomId('false').setLabel('No').setStyle(ButtonStyle.Danger)
|
||||
);
|
||||
await buttonPress.editReply({
|
||||
content: 'Is this your character?',
|
||||
@@ -155,9 +155,9 @@ module.exports = class AkinatorCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
const row = new MessageActionRow();
|
||||
const row = new ActionRowBuilder();
|
||||
row.addComponents(
|
||||
new MessageButton().setLabel('Akinator Website').setStyle('LINK').setURL('https://akinator.com/')
|
||||
new ButtonBuilder().setLabel('Akinator Website').setStyle(ButtonStyle.Link).setURL('https://akinator.com/')
|
||||
);
|
||||
if (win === 'time') {
|
||||
return buttonPress.editReply({ content: 'I guess your silence means I have won.', components: [row] });
|
||||
|
||||
@@ -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 { stripIndents } = require('common-tags');
|
||||
const logos = require('../../assets/json/logos');
|
||||
@@ -45,7 +45,7 @@ module.exports = class AnimeScoreCommand extends Command {
|
||||
memberName: 'anime-score',
|
||||
description: 'See if you can guess what a random anime\'s score is.',
|
||||
game: true,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks],
|
||||
credit: [
|
||||
{
|
||||
name: 'AniList',
|
||||
@@ -59,13 +59,13 @@ module.exports = class AnimeScoreCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
const anime = await this.getRandomAnime(msg.channel.nsfw);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x02A9FF)
|
||||
.setAuthor('AniList', logos.anilist, 'https://anilist.co/')
|
||||
.setAuthor({ name: 'AniList', iconURL: logos.anilist, url: 'https://anilist.co/' })
|
||||
.setImage(anime.coverImage.large || anime.coverImage.medium || null)
|
||||
.setTitle(anime.title.english || anime.title.romaji)
|
||||
.setDescription(`_${anime.startDate.year}, ${formats[anime.format]}_`)
|
||||
.setFooter(anime.id.toString());
|
||||
.setFooter({ text: anime.id.toString() });
|
||||
await msg.reply('**You have 15 seconds, what score do you think this anime has?**', { embeds: [embed] });
|
||||
const filter = res => {
|
||||
if (res.author.id !== msg.author.id) return false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const { createCanvas } = require('canvas');
|
||||
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789'.split('');
|
||||
|
||||
@@ -14,7 +15,7 @@ module.exports = class CaptchaCommand extends Command {
|
||||
usages: 2,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const questions = require('../../assets/json/google-feud');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
@@ -75,18 +75,18 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
}
|
||||
|
||||
makeEmbed(question, tries, suggestions, display) {
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x005AF0)
|
||||
.setTitle(`${question}...?`)
|
||||
.setDescription('Type the choice you think is a suggestion _without_ the question.')
|
||||
.setFooter(`${tries} ${tries === 1 ? 'try' : 'tries'} remaining!`);
|
||||
.setFooter({ text: `${tries} ${tries === 1 ? 'try' : 'tries'} remaining!` });
|
||||
for (let i = 0; i < suggestions.length; i++) {
|
||||
const num = formatNumber(10000 - (i * 1000));
|
||||
embed.addField(`❯ ${num}`, display[i], true);
|
||||
}
|
||||
if (suggestions.length % 3 !== 0 && suggestions.length > 3) {
|
||||
for (let i = 0; i < 3 - (suggestions.length % 3); i++) {
|
||||
embed.addField('\u200B', '\u200B', true);
|
||||
embed.addBlankField(true);
|
||||
}
|
||||
}
|
||||
return embed;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { Readable } = require('stream');
|
||||
@@ -20,8 +21,8 @@ module.exports = class GuessSongCommand extends Command {
|
||||
duration: 15
|
||||
},
|
||||
guildOnly: true,
|
||||
userPermissions: ['CONNECT', 'SPEAK'],
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
userPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const path = require('path');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { delay, verify } = require('../../util/Util');
|
||||
@@ -17,7 +18,7 @@ module.exports = class HearingTestCommand extends Command {
|
||||
duration: 10
|
||||
},
|
||||
guildOnly: true,
|
||||
userPermissions: ['CONNECT', 'SPEAK'],
|
||||
userPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const path = require('path');
|
||||
const { stripIndents } = require('common-tags');
|
||||
@@ -19,7 +20,7 @@ module.exports = class HorseRaceCommand extends Command {
|
||||
usages: 2,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
@@ -18,7 +19,7 @@ module.exports = class PokemonAdvantageCommand extends Command {
|
||||
usages: 2,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { Util: { escapeMarkdown } } = require('discord.js');
|
||||
const { escapeMarkdown } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { list, verify } = require('../../util/Util');
|
||||
const TarotDeck = require('../../structures/tarot/TarotDeck');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const request = require('node-superfetch');
|
||||
const difficulties = ['easy', 'medium', 'hard'];
|
||||
@@ -45,9 +45,9 @@ module.exports = class TrueOrFalseCommand extends Command {
|
||||
if (!body.results) return msg.reply('Oh no, a question could not be fetched. Try again later!');
|
||||
const correct = decodeURIComponent(body.results[0].correct_answer.toLowerCase());
|
||||
const correctBool = correct === 'true';
|
||||
const row = new MessageActionRow().addComponents(
|
||||
new MessageButton().setCustomId('true').setStyle('SUCCESS').setLabel('True'),
|
||||
new MessageButton().setCustomId('false').setStyle('DANGER').setLabel('False')
|
||||
const row = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId('true').setStyle(ButtonStyle.Success).setLabel('True'),
|
||||
new ButtonBuilder().setCustomId('false').setStyle(ButtonStyle.Danger).setLabel('False')
|
||||
);
|
||||
const questionMsg = await msg.reply(stripIndents`
|
||||
**You have 15 seconds to answer this question.**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
|
||||
module.exports = class WhosThatPokemonCryCommand extends Command {
|
||||
@@ -14,8 +15,8 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
|
||||
duration: 10
|
||||
},
|
||||
guildOnly: true,
|
||||
userPermissions: ['CONNECT', 'SPEAK'],
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
userPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
@@ -17,7 +18,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
usages: 2,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
game: true,
|
||||
credit: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user