'Discord.js buttons error (TypeError: INVALID_BUTTON_STYLE: An invalid button styles was provided)
I was try to use discord-buttons. and I was make some code and run it. but it wasn't work That was error in buttons style code. I'm use discord.js 12-, and made button with discord-button I don't know how to solve this problem. What I should do?
this is error
the bot is online!
C:\Users\user\Downloads\bot\node_modules\discord-buttons\src\v12\Util.js:13
throw new TypeError('INVALID_BUTTON_STYLE: An invalid button styles was provided');
^
TypeError: INVALID_BUTTON_STYLE: An invalid button styles was provided
at resolveStyle (C:\Users\user\Downloads\bot\node_modules\discord-buttons\src\v12\Util.js:13:13)
at MessageButton.setStyle (C:\Users\user\Downloads\bot\node_modules\discord-buttons\src\v12\Classes\MessageButton.js:31:13)
at Client.<anonymous> (C:\Users\user\Downloads\bot\index.js:28:14)
at Client.emit (node:events:394:28)
at MessageCreateAction.handle ot(C:\Users\user\Downloads\bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\user\Downloads\bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket ot(C:\Users\user\Downloads\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\user\Downloads\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage ot(C:\Users\user\Downloads\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\user\Downloads\bot\node_modules\ws\lib\event-target.js:132:16)
and this is my code
const { prefix, token } = require('./config.json');
const Discord = require("discord.js");
const client = new Discord.Client();
const Database = require("./Helpers/Database");
const { MessageButton } = require('discord-buttons')
.....
let button1 = new MessageButton()
.setLabel("test1")
.setStyle('ORANGE')
.setID("button1")
let button2 = new MessageButton()
.setStyle('BLURPLE')
.setLabel("test2")
.setID("button2")
let button3 = new MessageButton()
.setStyle('gray')
.setLabel("test3")
.setID("button3")
.....
message.author.send({embed: embed, buttons: [button1, button2, button3]})
Solution 1:[1]
According to the docs, they use grey with the 'e'. Not an 'a'. Simple mistake that can be easily corrected
let button3 = new MessageButton()
.setStyle('grey') //not 'gray'
.setLabel("test3")
.setID("button3")
Note: this package is deprecated with the release of discord.js v13. There are some other packages like discord-reply which are also deprecated as v13 has support for buttons and replies.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
