久久久久久久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 服務器時的歡迎消息)
主站蜘蛛池模板: 亚洲综合成人网 | 久久伊人影院 | 亚洲综合在线一区 | 国产精品中文字幕在线观看 | 国产激情在线观看 | 亚洲精品乱码久久久久v最新版 | 亚洲xx在线 | 国产精品久久久久久久久久久久久 | 亚洲欧美中文日韩在线v日本 | 手机看片1 | 国产精品久久久久久久一区二区 | 欧美视频中文字幕 | 国产精品性做久久久久久 | 日韩欧美在线视频一区 | 国产精品1区 | 亚洲精品国产偷自在线观看 | av毛片| 亚洲免费视频网站 | 色婷婷久久久久swag精品 | 日本a∨精品中文字幕在线 亚洲91视频 | 在线中文字幕av | 亚洲久久一区 | 欧美精品在线观看 | 精品中文视频 | 18性欧美| 亚洲国产小视频 | 罗宾被扒开腿做同人网站 | 69电影网 | 午夜一区二区三区在线观看 | 一区视频在线 | 国产99视频精品免费视频7 | 日日摸夜夜添夜夜添特色大片 | 日本一二区视频 | 成人免费视频 | 青青草精品视频 | 淫片一级国产 | 99在线播放 | 一区二区国产精品 | 午夜免费福利电影 | 国产一区久久久 | 91精品久久久|