Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
discordbot code error with coinflip command javascript

I'm pretty new to coding, and I'm trying to code a discord bot to flip a coin. I have edited and rewritten my code several times, and still can't get it to work.

Here's what I'm working with currently:

if (command === 'ht'){
        function doRandHT() {
            var rand = ['HEADS!','TAILS!'];
            return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
        }
        execute(message, args, Discord); {
            const newEmbed = new Discord.MessageEmbed()
            "title"; ('Here is the winner!'),
            "description"; doRandHT(),
            "color"; 7584788,
            message.channel.send({ embed });
        }

I'm sure it's something obvious but I just can't get it to work, what should I fix?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First of all the you make newembed a variable but never use it so you basically send nothing in the channel

second of all the way you make your embed is wrong, check out here on how to do it

so the working way of your code would be:

if (command === 'ht'){
    function doRandHT() {
        return (Math.floor(Math.random() * 2) == 0) ? 'HEADS!' : 'TAILS!';
    }
execute(message); {
    let embed = new Discord.MessageEmbed()
    .setTitle(`Here is the winner!`)
    .setDescription(doRandHT())
    .setColor("#73BC14")
    message.channel.send(embed)
   }
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda