【问题标题】:I am currently trying to write a ship code with discord.js but i can't get it to work我目前正在尝试使用 discord.js 编写船舶代码,但我无法让它工作
【发布时间】:2021-08-22 04:54:13
【问题描述】:

当我在 Visual Studio Code 上运行机器人并且它正常运行时,所有其他命令,但是当我尝试运行这个 ship 命令时没有任何反应,我的机器人没有发送任何内容,VS Code 也没有向我发送任何错误.

const Discord = require('discord.js');
require('discord-reply');
const getMember = require('functions.js')
const bot = new Discord.Client();

bot.on('ready', () => {
    console.log('hello mother')
    bot.user.setActivity('bia info')
});

module.exports.run = async (bot, message, args, prefix) => {
bot.on('message', (message) => {
    if (message.content == 'bia ship') { 
  let user = message.mentions.users.first()
  let RN = Math.floor(Math.random() * 100) 

  const UnLoveEmbed = new Discord.MessageEmbed()
  .setColor('#A14EFF')
  .setTitle('Uhm.. There is not a match. ???? ????')
  .setDescription(`'${message.author} shipped with ${user} gives ${RN}%'`)


  const LoveEmbed = new Discord.MessageEmbed()
  .setColor('#A14EFF')
  .setTitle('Looks like we have a couple here! ???? ????')
  .setDescription(`${message.author} shipped with ${user} gives ${RN}%`)


    if (RN > 50) {
    message.channel.send(LoveEmbed)
  } else {
    if (RN < 50) {
      message.channel.send(UnLoveEmbed)
    }
  }
}}
)};

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    我相信在 DiscordJS v13 中,您必须指定要发送这样的嵌入:

    channel.send({ embeds: [ExampleEmbed] });
    

    所以在你的情况下:

    message.channel.send({ embeds: [LoveEmbed] });
    //In stead of:
    message.channel.send(LoveEmbed);
    

    Source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-19
      • 2023-01-28
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多