I am trying to make a discord bot that can send random items from a provided data. Everything runs smooth, but I want to send those items in form of imbeds but i cant find a way to do it. I am attaching my code below
const jokes = [
'I went to a street where the houses were numbered 8k, 16k, 32k, 64k, 128k, 256k and 512k. It was a trip down Memory Lane.',
'“Debugging” is like being the detective in a crime drama where you are also the murderer.',
'The best thing about a Boolean is that even if you are wrong, you are only off by a bit.',
'A programmer puts two glasses on his bedside table before going to sleep. A full one, in case he gets thirsty, and an empty one, in case he doesnt.',
'If you listen to a UNIX shell, can you hear the C?',
'Why do Java programmers have to wear glasses? Because they dont C#.',
'What sits on your shoulder and says “Pieces of 7! Pieces of 7!”? A Parroty Error.',
'When Apple employees die, does their life HTML5 in front of their eyes?',
'Without requirements or design, programming is the art of adding bugs to an empty text file.',
'Before software can be reusable it first has to be usable.',
'The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.',
'I think Microsoft named .Net so it wouldnt show up in a Unix directory listing.',
'There are two ways to write error-free programs; only the third one works.',
];
module.exports={
name:'joke',
execute(message, arg){
message.channel.send(jokes[Math.floor(Math.random() * jokes.length)]);
}
}
CodePudding user response:
const { MessageEmbed } = require('discord.js');
const embed = new MessageEmbed().setDescription(jokes[Math.floor(Math.random() * jokes.length)]);
message.channel.send({embeds: [embed]});
https://discord.js.org/#/docs/discord.js/stable/class/MessageEmbed
CodePudding user response:
const jokes = [
'I went to a street where the houses were numbered 8k, 16k, 32k, 64k, 128k, 256k and 512k. It was a trip down Memory Lane.',
'“Debugging” is like being the detective in a crime drama where you are also the murderer.',
'The best thing about a Boolean is that even if you are wrong, you are only off by a bit.',
'A programmer puts two glasses on his bedside table before going to sleep. A full one, in case he gets thirsty, and an empty one, in case he doesnt.',
'If you listen to a UNIX shell, can you hear the C?',
'Why do Java programmers have to wear glasses? Because they dont C#.',
'What sits on your shoulder and says “Pieces of 7! Pieces of 7!”? A Parroty Error.',
'When Apple employees die, does their life HTML5 in front of their eyes?',
'Without requirements or design, programming is the art of adding bugs to an empty text file.',
'Before software can be reusable it first has to be usable.',
'The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.',
'I think Microsoft named .Net so it wouldnt show up in a Unix directory listing.',
'There are two ways to write error-free programs; only the third one works.',
];
const embed = new MessageEmbed()
.setTitle('Title here')
.setDescription(jokes[Math.floor(Math.random() * jokes.length)])
.setColor('color_here')
message.channel.send({embeds: [embed]})
//message.reply({embeds: [embed]})