Getting a user input after an Embed (Discord.js) - javascript

So im trying to make a sort of pokemon catching bot just for fun and to test my skill, I've invited my friend to help me. We're trying to make a random spawn and a catching mechanism. The catching mechaninism didn't really work well since it detect the user input before the embed not after the embed which is impossible to catch. Any help will be much appreciate.
bot.on("message", async message => {
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
let r = message.content.slice(bot.prefix.length+6)
let dex = Math.floor((Math.random() * 921) + 1);
let random = Math.floor((Math.random() * 5) + 1);
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) {
if(random===5){
const options = {
url: `https://pokeapi.co/api/v2/pokemon/${dex}`,
json: true
}
get(options).then(body => {
let Embed = new MessageEmbed()
.setTitle("A Wild pokemon has appeared")
.setDescription(`Quick, catch that pokemon!`)
.setThumbnail(body.sprites.front_default)
.setFooter(body.name)
.setColor("#00eaff")
message.channel.send(Embed);
})
get(options).then(body => {
if(message.content==(body.name)){
message.reply("You just caught a " + body.name);
}
else {
message.reply("Not that one!");
}
})
}
}

It is not impossible to catch. You can easily achieve this by using awaitMessages()
bot.on("message", async message => {
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
let r = message.content.slice(bot.prefix.length + 6)
let dex = Math.floor((Math.random() * 921) + 1);
let random = Math.floor((Math.random() * 5) + 1);
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) {
if (random === 5) {
const options = {
url: `https://pokeapi.co/api/v2/pokemon/${dex}`,
json: true
}
get(options).then(async body => {
let Embed = new MessageEmbed()
.setTitle("A Wild pokemon has appeared")
.setDescription(`Quick, catch that pokemon!`)
.setThumbnail(body.sprites.front_default)
.setFooter(body.name)
.setColor("#00eaff")
const msg = await message.channel.send(Embed);
const filter = m => m.author.id === message.author.id
msg.channel.awaitMessages(filter, { max: 1, time: 60000, errors: ['time'] }) // 1 minute timer & max of 1 attempt at answering
.then(collected => {
get(options).then(body => {
if (collected.first().content == (body.name)) {
message.reply("You just caught a " + body.name);
}
else {
message.reply("Not that one!");
}
})
})
.catch(() => message.reply('you did not guess in time!'));
})
}
}

Related

Getting 'Reply already sent or deferred' error on Discord interaction (djs)

I am currently building a trivia system and would like to reply every time a user submits an answer to a trivia question. However, I have the following problem with the script below:
const datahandler = require("../../dataHandler")
const { SlashCommandBuilder } = require('#discordjs/builders');
const { MessageEmbed } = require("discord.js");
const xml = require('xmlhttprequest').XMLHttpRequest
const triviahttp = new xml()
module.exports = {
data: new SlashCommandBuilder()
.setName('trivia')
.setDescription('Answer various trivia questions and earn some quick Jumobos!'),
async execute(interaction) {
await interaction.deferReply();
const difficulties = ['easy', 'medium', 'hard']
await triviahttp.open('GET', "https://opentdb.com/api.php?amount=1&type=multiple&difficulty=" + difficulties[Math.floor(Math.random()*difficulties.length)])
await triviahttp.send('');
triviahttp.addEventListener('load', async function() {
const data = JSON.parse(triviahttp.responseText)
const choices = ["", "", "", ""]
const allanswers = [data.results[0].incorrect_answers[0], data.results[0].incorrect_answers[1], data.results[0].incorrect_answers[2], data.results[0].correct_answer]
let randomanswer = Math.floor(Math.random()*allanswers.length)
choices[0] = allanswers[randomanswer]
await allanswers.splice(randomanswer, 1)
randomanswer = Math.floor(Math.random()*allanswers.length)
choices[1] = allanswers[randomanswer]
await allanswers.splice(randomanswer, 1)
randomanswer = Math.floor(Math.random()*allanswers.length)
choices[2] = allanswers[randomanswer]
await allanswers.splice(randomanswer, 1)
randomanswer = Math.floor(Math.random()*allanswers.length)
choices[3] = allanswers[randomanswer]
await allanswers.splice(randomanswer, 1)
randomanswer = Math.floor(Math.random()*allanswers.length)
let prize = 0;
if(data.results[0].difficulty == 'easy') {
prize = "10"
} else if(data.results[0].difficulty == "medium") {
prize = "20"
} else if (data.results[0].difficulty == "hard") {
prize = "50"
}
const triviaembed = new MessageEmbed()
.setColor('#34faa4')
.setTitle("<:chat:924420173040066641> Trivia question!")
.setDescription(`Answer the following question to win some Jumobos. The harder the question, the more Jumobos you may earn! You have 10 seconds to answer the following question. **Reward:** <:jumobo:941073795232460951> ${prize} \n\n **Q:** ${data.results[0].question} \n\n **A.** ${choices[0]} \n **B.** ${choices[1]} \n **C.** ${choices[2]} \n **D.** ${choices[3]} \n\n Please respond with an answer, **A-B-C-D**.`)
await interaction.reply({ embeds: [triviaembed], fetchReply: true })
const filter = m => m.content === "A" || m.content === "B" || m.content === "C" || m.content === "D" && m.author.id == interaction.user.id;
const collector = interaction.channel.createMessageCollector({filter , max: 1, time: 10000})
collector.on('collect', message => {
message.delete()
collector.stop()
})
collector.on('end', async collected => {
if(collected.size === 0) {
await interaction.followUp("You have ran out of time!")
return;
}
let convertlettertochoice = '';
if(collected.first().content == "A") convertlettertochoice = "0";
if(collected.first().content == "B") convertlettertochoice = "1";
if(collected.first().content == "C") convertlettertochoice = "2";
if(collected.first().content == "D") convertlettertochoice = "3";
console.log(convertlettertochoice)
if(choices[convertlettertochoice] == data.results[0].correct_answer) {
await interaction.editReply({content: "Hooray! You got this one correct. You have been awarded <:jumobo:941073795232460951> **" + prize + "**.", embeds: []})
} else {
await interaction.editReply({content: "You got this one incorrect. Yikes! :pensive:", embeds: []})
}
setTimeout(async () => {
await interaction.deleteReply();
}, 5000);
})
})
}
};
I get the following error in the console:
C:\Users\kkost\Desktop\BristoSystems\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:90
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
^
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
at CommandInteraction.reply (C:\Users\kkost\Desktop\BristoSystems\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:90:46)
at exports.XMLHttpRequest.<anonymous> (C:\Users\kkost\Desktop\BristoSystems\src\commands\economy\trivia.js:46:36)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}
I have tried multiple solutions from many other fellow coders but couldn't figure it out so far. Help would be appreciated. Thanks.
On line 46 you are trying to reply, change this to editReply.
Change: await interaction.reply({ embeds: [triviaembed], fetchReply: true })
To: await interaction.editReply({ embeds: [triviaembed] })
Also it might be worth making your code more tidy, then you won't have these issues.

Creating a BulkDelete command | Discord.JS

As you read by the title I'm trying to make a clear command for my Discord bot, but I can't get it to work.
Here's a snippet:
client.on('message', message => {
if (message.content = "clear") {
let args = message.content.substring(prefix.length).split(" ");
var deleteCount = message.guild.members.cache.get(args[1]);
if (message.member.hasPermission("MANAGE_MESSAGES")) {
const deleteCount = args[2];
const fetched = ({
limit: deleteCount
});
message.delete(fetched)
try {
} catch (error) {
}(error => message.reply(`Couldn't delete messages because of: ${error}`));
if (!deleteCount || deleteCount < 2 || deleteCount > 100)
return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
message.channel.send('Successfully deleted ' + `${deleteCount}` + 'messages!');
}
}
});
Also, don't ask me what I'm doing and why I copied some stuff from other people trying to make it but the code was outdated.
Can someone help me?
client.on("message", message => {
if (message.content.indexOf(prefix) !== 0) {return false};
const arguments = message.content.slice(prefix.length).trim().split(/ +/g);
const command = arguments.shift().toLowerCase();
if (command == "clear") {
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You are not allowed to use this command.");
if (!arguments[0]) return message.channel.send("Please provide a number between 2 and 100.")
if (arguments[0] < 2 || arguments[0] > 100) return message.channel.send("Please provide a number between 2 and 100.")
message.channel.bulkDelete(arguments[0]).then(messages => {
message.channel.send(`Deleted ${messages.size} messages.`);
}).catch(e => console.log(e));
};
});

Discord.js Bot giveaway command : embedSent.reactions.get is not a function

I am trying to make a Discord.js giveaway command that send an embed, save it to the variable embedSent then collect the reactions after the TimeOut with the reactions.get() method, but I keep getting the error TypeError: embedSent.reactions.get is not a function Here is the part of my code :
var embed = new Discord.MessageEmbed();
embed.setColor(0x3333ff);
embed.setTitle("Nouveau Giveaway !");
embed.setDescription("**" + item + "**");
embed.addField(`Durรฉe : `, ms(ms(time), {
long: true
}), true);
embed.setFooter("Rรฉagissez ร  ce message avec ๐ŸŽ‰ pour participer !");
var embedSent = await message.channel.send(embed);
embedSent.react("๐ŸŽ‰");
setTimeout(function () {
var peopleReacted = embedSent.reactions.get("๐ŸŽ‰").users.filter(user => user.id !== client.user.id).array()
}, time);
Ok, after almost 2 months, I finally figured it out. The full, working command (DiscordJS v12) :
if (command == "giveaway") {
// !giveaway {time s/m/d} {item}
const messageArray = message.content.split(" ");
if (!message.member.hasPermission(["ADMINISTRATOR"])) return message.channel.send("You don't have enough permissions to start a giveaway !")
var item = "";
var time;
var winnerCount;
for (var i = 1; i < args.length; i++) {
item += (args[i] + " ");
}
time = args[0];
if (!time) {
return message.channel.send(`Invalid duration provided`);
}
if (!item) {
item = "No title"
}
var embed = new Discord.MessageEmbed();
embed.setColor(0x3333ff);
embed.setTitle("New Giveaway !");
embed.setDescription("**" + item + "**");
embed.addField(`Duration : `, ms(ms(time), {
long: true
}), true);
embed.setFooter("React to this message with ๐ŸŽ‰ to participate !");
var embedSent = await message.channel.send(embed);
embedSent.react("๐ŸŽ‰");
setTimeout(async () => {
try{
const peopleReactedBot = await embedSent.reactions.cache.get("๐ŸŽ‰").users.fetch();
var peopleReacted = peopleReactedBot.array().filter(u => u.id !== client.user.id);
}catch(e){
return message.channel.send(`An unknown error happened during the draw of the giveaway **${item}** : `+"`"+e+"`")
}
var winner;
if (peopleReacted.length <= 0) {
return message.channel.send(`Not enough participants to execute the draw of the giveaway **${item}** :(`);
} else {
var index = Math.floor(Math.random() * peopleReacted.length);
winner = peopleReacted[index];
}
if (!winner) {
message.channel.send(`An unknown error happened during the draw of the giveaway **${item}**`);
} else {
console.log(`Giveaway ${item} won by ${winner.toString()}`)
message.channel.send(`๐ŸŽ‰ **${winner.toString()}** has won the giveaway **${item}** ! Congratulations ! ๐ŸŽ‰`);
}
}, ms(time));
}
Hope it helped some !
I guess this giveaway command works for me - Discord.js V13
don't forget to have npm i ms installed if you haven't already
const { Client, Intents, CommandInteraction, ReactionUserManager } = require('discord.js');
const INTENTS = new Intents(32767); // 32767 == full intents, calculated from intent calculator
const client = new Client({
intents: INTENTS
});
const Discord = require('discord.js');
const ms = require('ms') // make sure package ms is downloaded in console, to do this, simply type: npm i ms in your terminal
// https://www.npmjs.com/package/ms
client.once("ready" , () => {
console.log("I am online!")
});
client.on('messageCreate', async message => {
const prefix = "!" // this can be any prefix you want
let args = message.content.substring(prefix.length).split(" ")
// COMMAND FORMAT: !startgiveaway {duration} {winners} {#channel} {prize}
// E.g. !startgiveaway 24h 3w #giveaways Free Discord Nitro
if ((message.content.startsWith(`${prefix}startgiveaway`))) { // this condition can be changed to any command you'd like, e.g. `${prefix}gstart`
if (message.member.roles.cache.some(role => (role.name === 'Giveaway') )) { // user must have a role named Giveaway to start giveaway
let duration = args[1];
let winnerCount = args[2];
if (!duration)
return message.channel.send('Please provide a duration for the giveaway!\nThe abbreviations for units of time are: `d (days), h (hours), m (minutes), s (seconds)`');
if (
!args[1].endsWith("d") &&
!args[1].endsWith("h") &&
!args[1].endsWith("m") &&
!args[1].endsWith("s")
)
return message.channel.send('Please provide a duration for the giveaway!\nThe abbreviations for units of time are: `d (days), h (hours), m (minutes), s (seconds)`');
if (!winnerCount) return message.channel.send('Please provide the number of winners for the giveaway! E.g. `1w`')
if (isNaN(args[2].toString().slice(0, -1)) || !args[2].endsWith("w")) // if args[2]/winnerCount is not a number (even after removing end 'w') or args[2] does not end with 'w', condition returns:
return message.channel.send('Please provide the number of winners for the giveaway! E.g. `3w`');
if ((args[2].toString().slice(0, -1)) <= 0)
return message.channel.send('The number of winners cannot be less than 1!');
let giveawayChannel = message.mentions.channels.first();
if (!giveawayChannel || !args[3]) return message.channel.send("Please provide a valid channel to start the giveaway!")
let prize = args.slice(4).join(" ");
if (!prize) return message.channel.send('Please provide a prize to start the giveaway!');
let startGiveawayEmbed = new Discord.MessageEmbed()
.setTitle("๐ŸŽ‰ GIVEAWAY ๐ŸŽ‰")
.setDescription(`${prize}\n\nReact with ๐ŸŽ‰ to participate in the giveaway!\nWinners: **${winnerCount.toString().slice(0, -1)}**\nTime Remaining: **${duration}**\nHosted By: **${message.author}**`)
.setColor('#FFFFFF')
.setTimestamp(Date.now() + ms(args[1])) // Displays time at which the giveaway will end
.setFooter("Giveaway ends");
let embedGiveawayHandle = await giveawayChannel.send({embeds: [startGiveawayEmbed]})
embedGiveawayHandle.react("๐ŸŽ‰").catch(console.error);
setTimeout(() => {
if (embedGiveawayHandle.reactions.cache.get("๐ŸŽ‰").count <= 1) {
return giveawayChannel.send("Nobody joined the giveaway :(")
}
if (embedGiveawayHandle.reactions.cache.get("๐ŸŽ‰").count <= winnerCount.toString().slice(0, -1)) { // this if-statement can be removed
return giveawayChannel.send("There's not enough people in the giveaway to satisfy the number of winners!")
}
let winner = embedGiveawayHandle.reactions.cache.get("๐ŸŽ‰").users.cache.filter((users) => !users.bot).random(winnerCount.toString().slice(0, -1));
const endedEmbedGiveaway = new Discord.MessageEmbed()
.setTitle("๐ŸŽ‰ GIVEAWAY ๐ŸŽ‰")
.setDescription(`${prize}\n\nWinner(s): ${winner}\nHosted By: **${message.author}**\nWinners: **${winnerCount.toString().slice(0, -1)}**\nParticipants: **${embedGiveawayHandle.reactions.cache.get("๐ŸŽ‰").count - 1}**\nDuration: **${duration}**`)
.setColor('#FFFFFF')
.setTimestamp(Date.now() + ms(args[1])) // Displays time at which the giveaway ended
.setFooter("Giveaway ended");
embedGiveawayHandle.edit({embeds:[endedEmbedGiveaway]}); // edits original giveaway message to show that the giveaway ended successfully
const congratsEmbedGiveaway = new Discord.MessageEmbed()
.setDescription(`๐Ÿฅณ Congratulations ${winner}! You just won **${prize}**!`)
.setColor('#FFFFFF')
giveawayChannel.send({embeds: [congratsEmbedGiveaway]}).catch(console.error);
}, ms(args[1]));
} // end "Giveaway" role condition
}
})
client.login('INSERT YOUR BOT TOKEN HERE');

How can I go about handling an error, ignoring it and continuing with the function? discord.js

I'm trying to dm all users in my private server with all my friends however some of them don't want to be dmed so they turn off their dms. Because of this, I get an error which stops the bot from continuing on to the other users. How can I skip over that user when the error is found and tell my bot to continue to dm the next user after.
heres my code
const commando = require('discord.js-commando');
const app = require('../../app.js');
const config = require('../../config.json');
const Discord = require('discord.js');
class DMallCommand extends commando.Command {
constructor(client){
super(client, {
name: `dmall`,
group: 'dms',
memberName: 'dmall',
description: 'Sends message provided to all members of the guild.',
examples: [ `${config.prefix}dmall Hey everyone! This might reach more people than a mass ping...` ]
});
}
async run(message, args){
let dmGuild = message.guild;
let role = message.mentions.roles.first();
var msg = message.content;
try {
msg = msg.substring(msg.indexOf("dmall") + 5);
} catch(error) {
console.log(error);
return;
}
if(!msg || msg.length <= 1) {
const embed = new Discord.RichEmbed()
.addField(":x: Failed to send", "Message not specified")
.addField(":eyes: Listen up!", "Every character past the command will be sent,\nand apparently there was nothing to send.");
message.channel.send({ embed: embed });
return;
}
let memberarray = dmGuild.members.array();
let membercount = memberarray.length;
let botcount = 0;
let successcount = 0;
console.log(`Responding to ${message.author.username} : Sending message to all ${membercount} members of ${dmGuild.name}.`)
for (var i = 0; i < membercount; i++) {
let member = memberarray[i];
if (member.user.bot) {
console.log(`Skipping bot with name ${member.user.username}`)
botcount++;
continue
}
let timeout = Math.floor((Math.random() * (config.wait - 0.01)) * 1000) + 10;
await sleep(timeout);
if(i == (membercount-1)) {
console.log(`Waited ${timeout}ms.\t\\/\tDMing ${member.user.username}`);
} else {
console.log(`Waited ${timeout}ms.\t|${i + 1}|\tDMing ${member.user.username}`);
}
try {
member.send(`${msg} \n #${timeout}`);
successcount++;
} catch (error) {
console.log(`Failed to send DM! ` + error)
}
}
console.log(`Sent ${successcount} ${(successcount != 1 ? `messages` : `message`)} successfully, ` +
`${botcount} ${(botcount != 1 ? `bots were` : `bot was`)} skipped.`);
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = DMallCommand;
I understand I am not handling any errors but I am not sure how to go about this and could really use some help
Also here is my bot.js code
const Discord = require('discord.js');
const figlet = require('figlet');
const colors = require('colors');
const readline = require('readline');
const commando = require(`discord.js-commando`);
const config = require('./config.json');
const bot = new commando.Client({
commandPrefix:'ยฃ',
owner: config.id
});
const cmdsArray = [
"dmall <message>",
"dmrole <role> <message>"
];
bot.on("ready", () => {
clear();
console.log('______')
bot.user.setActivity('PRDX');
});
bot.on("error", (error) => {
bot.login(config.token);
});
bot.registry.registerGroup('dms', 'help');
bot.registry.registerDefaults();
bot.registry.registerCommandsIn(__dirname + "/commands");
if (process.env.BOT_TOKEN) bot.login(process.env.BOT_TOKEN);
else bot.login(config.token);
}
Anywhere in your code use an error event listener
client.on("error", () => { client.login(token) });
You'll want to catch the error, basically, if that error happens, you want it to just pass by and ignore the error. In Javascript this is known as try and catch. Read about it below then apply it to wherever the error is being identified.
https://www.w3schools.com/js/js_errors.asp
You can use .catch() block, member.send('Message') return a promise with succes sended message or error. So you can use
member.send('message').catch(console.error)

Loop for display help command

Actually, i try to create a bot with discord.js and i try to do a help command.
i don't understand why my loop do this (i know it's not a good way for this)
let i = 0;
const embed = new RichEmbed();
if (args.length < 1) {
embed.setColor('#5B4DCA');
while (i < list_groups.length) {
let x = 0;
embed.setTitle(`${list_groups[i]}`)
while (x < groups.length) {
if (groups[x] === list_groups[i]) {
embed.addField('test1', 'test2')
}
x++;
}
message.channel.send(embed)
i++;
}
}
"Modรฉrations" is supposed to display one command, "level & rank" too, "Outils" 4 command and "Sondage" too
enter image description here
I think you solutuion its not right way. If you will have more then 10 groups bot will spam commands list. The 1 way to do it its display all categories list if args.length===0, if args !==0 you try to find all commands in this category. To discord embed you can add only 18 fields, so if you have more then 18 command in categroy you will get api error. So you need spliced commands to pages.
This code will display all categories if args.length === 0, or command groups not fined.
If group fined bot send embed message with command in group (max 10), and react message if pages more then 1, so user can change page with reaction.
const {Discord,RichEmbed} = require('discord.js');
const {prefix,token,classic_roles} = require('../config.json');
const logs = require('../logs/logs');
module.exports.run = async (bot, message, args) => {
if(args.length === 0) {
//Show user all allowed groups commands
let commandCategories = bot.commands.map(command => `!help ${command.help.groups}`).filter(onlyUnique).join('\n') //find all categories and get onlyUnique
let helpMessage = `**The list of command groups:**\n\n ${commandCategories}`
let Embed = new Discord.RichEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarUrl)
.setDescription(helpMessage)
.setColor('#e0c40b')
message.channel.send(Embed)
} else {
//try find required group
let commandsInCategory = bot.commands.filter(command => command.help.groups === args.join(' ').toLowerCase())
if(commandsInCategory.size === 0) {
// if no group find, then display user list of groups
let commandCategories = bot.commands.map(command => `!help ${command.help.groups}`).filter(onlyUnique).join('\n')
let helpMessage = `**For get command list use**\n\n ${commandCategories}`
let Embed = new Discord.RichEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarUrl)
.setDescription(helpMessage)
.setColor('#e0c40b')
message.channel.send(Embed)
return
}
let counter = 0
let allCommands = []
commandsInCategory.map(command => {
allCommands.push({
name: command.help.name,
description: command.help.description
})
})
allCommands = generateHelpArray(allCommands)
//for better display, we will display only 10 in page
let Embed = new Discord.RichEmbed()
Embed.setAuthor(message.author.tag, message.author.displayAvatarUrl)
Embed.setDescription(`The list command of group : **${args.join(' ')}**`)
allCommands[counter].map(command => {
Embed.addField(`**${command.name}**`,`${command.description}`,false)
})
Embed.setColor('#E8DB0E')
Embed.setFooter(`Page ${counter+1} of ${allCommands.length}`)
message.channel.send(Embed).then(msg => {
if(allCommands.length < 2) return
// To change page we will use react emoji
msg.react(`โ—€๏ธ`).then(() => msg.react('โ–ถ๏ธ'))
const filter = (reaction, user) => {
return [`โ—€๏ธ`, 'โ–ถ๏ธ'].includes(reaction.emoji.name) && user.id === message.author.id;
};
const collector = msg.createReactionCollector(filter, { max:50, time: 60000 });
collector.on('collect', (reaction, reactionCollector) => {
if (reaction.emoji.name === `โ—€๏ธ`) {
//Change counter, remove user reaction and call change embed function
reaction.remove(message.author.id)
counter-=1
if(counter < 0) counter = 0
editEmbed(message, msg, counter, args.join(' '), allCommands)
} else if (reaction.emoji.name === `โ–ถ๏ธ`) {
//Change counter, remove user reaction and call change embed function
reaction.remove(message.author.id)
counter+=1
if(counter >= allCommands.length) counter = allCommands.length -1
editEmbed(message, msg, counter, args.join(' '), allCommands)
}
});
collector.on('end', (reaction, reactionCollector) => {
msg.clearReactions()
})
})
}
}
module.exports.help = {
name: "help",
description: "Vous permet d'obtenir toutes les commandes accessibles pour vos rรดles.",
access: "Public",
groups: "Outils"
}
const onlyUnique = (value, index, self) => {
return self.indexOf(value) === index;
}
const editEmbed = (message, msg, counter, category, allCommands) => {
let Embed = new Discord.RichEmbed()
Embed.setAuthor(message.author.tag, message.author.displayAvatarURL)
Embed.setDescription(`The list command of group : **${category}**`)
Embed.setColor('#E8DB0E')
allCommands[counter].map(command => {
Embed.addField(`**${command.name}**`,`${command.description}`,false)
})
Embed.setFooter(`Page ${counter+1} of ${allCommands.length}`)
msg.edit(Embed)
}
const generateHelpArray = (arr) => {
let newArray = [];
for (let i = 0; i < arr.length; i+=10) {
newArray.push(arr.slice(i,i+10))
}
return newArray
}

Categories