【问题标题】:I keep getting an error in discord.js "discord is not defined" OR I get no response from the bot. Not even an error/我在 discord.js 中不断收到错误“未定义不和谐”,或者我没有收到机器人的响应。甚至没有错误/
【发布时间】:2020-08-21 22:57:17
【问题描述】:

我正在使用 discord.js 编写一个不和谐机器人。 出于某种原因,它说Discord not defined 错误或机器人没有响应。请问你能帮帮我吗?我以前从未遇到过这个错误。这是代码。 我已将此命令包含在同一个 main.js 文件中:

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

  reporthelp = "Report a user. Requires a channel named `reports`to work!";
  kickhelp = "Kick a user from the server. Requires a channel named `incidents` to work; you must have the manage messages permission.";
  banhelp = "Ban a user from the server. Requires a channel named `incidents` to qork; toy need the BAN MEMBERS permission to use this command!";
  warnhelp = "**COMMAND COMING SOON!**";
  requiredperms = "**Embed Links, channel named `incidents`; channel named `reports`; channel named `suggestions`; Kick Members, Ban Members, Manage Roles, Manage Members.**"
  helpEmbed = new Discord.RichEmbed()

  .setDescription(" ???? **__Help Is Here!__** ????")
  .setColor("#936285")
  .addField("**/report @user <reason>**", reporthelp)
  .addField("**(COMING SOON)** /warn @user <reason>", warnhelp)
  .addField("**/kick @user <reason>**", kickhelp)
  .addField("**/ban @user <reason>**", banhelp)
  .addField("**/mytag**", "Shows you **your** discoord username#discrim and your user ID. Requires Embed Links permission.")
  .addField("**/invite**", "Get a linkto incite meto our server, and an invite link to my suppoer server")
  .addField("**/owner**", "see who currently owns the bot")
  .addField("**/git**", "**SOURCE CODE AVAILIBLE SOON**")
  .addField("**/token**", "View the bot's super secret bot token!")
  .addField("**/serverinfo**", "displays some basic server information!")
  .addField("**/botinfo**", "displays basic bot information!")
  .addField("**/ping**", "Get the bot to respond with `pong` ")
  .addField("**/hosting**", "Bot finds a good website for bot/web hosting")
  .addField("**/quotes**", "bot responds with some lovely quotes!")
  .addField("**__Required Permissions__**", requiredperms)
 // .addField("**COMING SOON!**/suggest <suggestion>", "suggest something. Requires channel named `suggestions`")
  .setTimestamp()
  .setFooter("Use /invite to invite me to your server!")


  return message.channel.send({embed: helpEmbed});


}

这就是我定义一切的方式:

const botconfig = require("./botconfig.json");
const tokenfile = require("./token.json");
const Discord = require("discord.js");

const bot = new Discord.Client({disableEveryone: true});

bot.on("ready", async () => {
  console.log(`${bot.user.username} is active in ${bot.guilds.size} servers!`);

  bot.user.setActivity("rewriteing main.js...", {type: "WATCHING"});

  //bot.user.setGame("Lookin' out for ya!");
});


bot.on("message", async message => {
  if(message.author.bot) return;
  if(message.channel.type === "dm") return;

  const prefix = botconfig.prefix;
  const messageArray = message.content.split(" ");
  const cmd = messageArray[0];
  const args = messageArray.slice(1);

  const bicon = bot.user.displayAvatarURL;

我要么没有响应/错误,要么收到错误discord is not defined

我也是新手,不好意思如果没问清楚的话……

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    代码是正确的,但我在文件的不同部分重新定义了discord....

    我的建议是重新阅读代码!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-17
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 2021-02-13
      • 2022-01-12
      相关资源
      最近更新 更多