久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用不和諧按鈕時出錯:“類擴展值未定義不是構

Error using discord-buttons: quot;Class extends value undefined is not a constructor or nullquot;(使用不和諧按鈕時出錯:“類擴展值未定義不是構造函數或空值)
本文介紹了使用不和諧按鈕時出錯:“類擴展值未定義不是構造函數或空值"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

I tried to make a button in Discord.js. However, when I wrote the code, I found that there was an error during startup.

I don't know why this error is happening. I checked many related questions online, but none of my problems were solved, and I even became even more confused.

This is my code:

const config = require("./config.json");
const Discord = require('discord.js');
const bot = new Discord.Client();
require('discord-buttons')(client);
const fs = require("fs");
const client = new Discord.Client({disableEveryone: false});
const moment = require("moment");
const { MessageButton, MessageActionRow } = require('discord-buttons')

client.commands = new Discord.Collection();

fs.readdir("./commands/", (err, files) => {

  if(err) console.log(err);
  let jsfile = files.filter(f => f.split(".").pop() === "js");
  if(jsfile.length <= 0){
    console.log("XX");
    return;
  }
  jsfile.forEach((f, i) =>{
    let props = require(`./commands/${f}`);
    client.commands.set(props.help.name, props);
  });
});

    client.on('message', async message => {
      if(message.content === "buttonstest"){
      const button = new MessageButton()
      .setLabel("test")
      .setStyle("green")
      .setID("btn1")
      var embed = new Discord.RichEmbed()
  .setColor("#FFFFFF")
  .setTitle("test")
    
      message.channel.send(embed, button);
      }
    })
        
client.on("message", async message => {
  if(message.author.bot) return;
  if(message.channel.type === "dm") return;

  let prefix = config.prefix;
  let messageArray = message.content.split(" ");
  let cmd = messageArray[0];
  let args = messageArray.slice(1);
  let commandfile = client.commands.get(cmd.slice(prefix.length));
  if(commandfile) commandfile.run(client,message,args);
});

client.login(config.token)

This is the error message:

I have no name!@f7808405-1373-45ee-bac7-0059f94bd574:~$ /home/container/node_modules/discord.js-buttons/src/Classes/APIMessage.js:5
class sendAPICallback extends APIMessage {
                              ^

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/home/container/node_modules/discord.js-buttons/src/Classes/APIMessage.js:5:31)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/container/node_modules/discord.js-buttons/src/Classes/Message.js:3:20)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)

解決方案

In Discord.js v13, the API message class has been renamed to MessagePayload. APIMessage would therefore be undefined.

This error is occurring in the discord-buttons module. Discord.js v13 supports buttons so you do not need this module. See the Discord.js guide on buttons for more details.

To send a button, you could use this code:

client.on('message', async message => {
  if(message.content === "buttonstest"){
    const button = new Discord.MessageButton()
      .setLabel("test")
      .setStyle("SUCCESS")
      .setCustomId("btn1");
    // Note that RichEmbed was renamed to MessageEmbed in v12
    const embed = new Discord.MessageEmbed()
      .setColor("#FFFFFF")
      .setTitle("test");
    message.channel.send({
      embeds: [embed],
      components: [{components: [button]}]
      // alternatively
      // components: [new Discord.MessageActionRow([button])] 
    });
  }
});

You should also take a look at the Discord.js v13 upgrade guide.

這篇關于使用不和諧按鈕時出錯:“類擴展值未定義不是構造函數或空值"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 91免费福利在线 | 日本精品视频在线观看 | 91在线影院 | 日韩在线 | 日韩在线 | 久久神马 | 中文字幕高清 | 午夜寂寞福利视频 | 亚洲成人免费 | 欧美 日韩 国产 一区 | 欧美成人一级 | 高清一区二区三区 | 欧美一级黄色网 | 久久精品一区二区三区四区 | 国产精品国产三级国产aⅴ无密码 | 国产乱码精品一区二三赶尸艳谈 | 天天色综| 成人在线免费视频观看 | 成人深夜福利在线观看 | 在线播放国产一区二区三区 | 精品国产一区二区三区久久久蜜月 | 欧美中文字幕一区二区三区亚洲 | 欧州一区二区三区 | 色综合一区 | 天天操天天射天天舔 | 亚洲成av人片在线观看 | 日韩精品一区二区三区中文在线 | 91精品麻豆日日躁夜夜躁 | 91精品久久久久久久久久入口 | 久久精品| 欧美8一10sex性hd | 综合激情av | 国产精品免费一区二区三区四区 | 亚洲综合大片69999 | 91精品成人久久 | 久久99精品久久久 | av天空| 国产伦一区二区三区 | a级免费黄色片 | 中文字幕第一页在线 | 在线看h|