簡體   English   中英

機器人不回復消息

[英]The bot does not respond to the message

我開始了解 discord.js 但現在我正面臨這個問題。 我嘗試了一些意圖,但我無法修復它。

const Discord = require("discord.js");
const client = new Discord.Client({ intents: 3276799 });
const config = require("./config.json");

  client.on("message", async message => {
  
      if(message.author.bot) return;
      if(message.channel.type === "dm") return;
      if(!message.content.startsWith(config.prefix)) return;
  
    const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
    const comando = args.shift().toLowerCase();
    
    // comando ping
    if(comando === "ping") {
      const m = await message.channel.send("Ping?");
      m.edit(`Pong! A Latência é ${m.createdTimestamp - message.createdTimestamp}ms. A Latencia da API é ${Math.round(client.ping)}ms`);
    }
  
  client.login(config.token);

client.on掛鈎缺少右括號,因此您的代碼應如下所示:

const Discord = require("discord.js");
const client = new Discord.Client({ intents: 3276799 });
const config = require("./config.json");

client.on("message", async message => {

    if(message.author.bot) return;
    if(message.channel.type === "dm") return;
    if(!message.content.startsWith(config.prefix)) return;

  const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  const comando = args.shift().toLowerCase();
  
  // comando ping
  if(comando === "ping") {
    const m = await message.channel.send("Ping?");
    m.edit(`Pong! A Latência é ${m.createdTimestamp - message.createdTimestamp}ms. A Latencia da API é ${Math.round(client.ping)}ms`);
  }
})

client.login(config.token);

暫無
暫無

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

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