簡體   English   中英

我的代碼有什么問題? 我沒有得到錯誤; 我沒有得到任何回應

[英]Whats wrong with my code? I don't get an error; I get no response what so ever

我不明白我的代碼有什么問題......

用法:

/建議

bot將建議發送到名為sugestions的頻道這里是meh代碼:

if(cmd === `${prefix}suggest`){

  // USAGE: 
  // /suggest this is the suggestion

  let suggestion = args.join(" ").slice(22);

  let suggestEmbed = new Discord.RichEmbed()
  .setDescription("~~-------~~**__NEW SUGGESTION!__**~~-------~~")
  .setColor("#ff0000")
  .addField("Suggestion By", `${message.author} (${message.author.id})`)
  .addField("Channel", message.channel)
  .addField("Time", message.createdAt)
  .addField("Suggestion", suggestion)
  .setTimestamp()
  .setFooter("Use /invite to invite me to your server!");

  let suggestchannel = message.guild.channels.find(`name`, "suggestions");
  if(!suggestchannel) return message.channel.send("Couldn't find suggestions channel. Please **create one for this command to work!**");


  message.delete().catch(O_o=>{});
  suggestchannel.send(suggestEmbed);

  return;
}

您的代碼行suggestchannel.send(...)犯了一個錯誤。 您不能將嵌入作為消息內容發送,因為它必須是一個字符串 在這里你可以找到更多關於這個的信息: https//discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo = send

這是更正后的代碼,請嘗試使用以下內容:

if (cmd === `${prefix}suggest`) {
    // USAGE:
    // /suggest this is the suggestion

    const suggestion = args.join(' ').slice(22);

    const suggestEmbed = new Discord.RichEmbed()
        .setDescription('~~-------~~**__NEW SUGGESTION!__**~~-------~~')
        .setColor('#ff0000')
        .addField('Suggestion By', `${message.author} (${message.author.id})`)
        .addField('Channel', message.channel)
        .addField('Time', message.createdAt)
        .addField('Suggestion', suggestion)
        .setTimestamp()
        .setFooter('Use /invite to invite me to your server!');

    const suggestchannel = message.guild.channels.find(`name`, 'suggestions');
    if (!suggestchannel) return message.channel.send("Couldn't find suggestions channel. Please **create one for this command to work!**");


    message.delete().catch(O_o => {});
    suggestchannel.send({ embed: suggestEmbed });
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM