timotejroiko / discord.js-light

All the power of discord.js, zero caching. This library modifies discord.js's internal classes and functions in order to give you full control over its caching behaviour.
Apache License 2.0
292 stars 29 forks source link

Buttons Support #62

Closed V1rtuaI closed 3 years ago

V1rtuaI commented 3 years ago

Are you able to add buttons support to djs light as per the djs update?

timotejroiko commented 3 years ago

It will be added once discord.js commits the PR to master. Right now its still an unfinished draft so it might take a while.

davipatricio commented 3 years ago

Are you able to add buttons support to djs light as per the djs update?

Released and now supported by discord.js-light πŸŽ‰

V1rtuaI commented 3 years ago

Next up support for Eris library? πŸ₯ΊπŸ₯Ί

Vexcited commented 3 years ago

How do you add buttons ? When I want to use discord-buttons, I need to bypass the version of Discord like this

const { version } = require("discord.js");
const Discord = require("discord.js-light");
Discord.version = version;

or else I got a error saying that .\v3\Classes doesn't exist.

But now I get a new error:

Error: The class/prototype returned from the extender function must extend the existing structure class/prototype (received function ExtendedTextChannel extends TextChannel; expected extension of ExtendedTextChannel).
    at Function.extend (C:\Users\vexit\Documents\GitHub\rikka-discord\node\node_modules\discord.js\src\util\Structures.js:82:13)
    at module.exports (C:\Users\vexit\Documents\GitHub\rikka-discord\node\node_modules\discord-buttons\src\index.js:22:16)    
    at Object.runCommand (C:\Users\vexit\Documents\GitHub\rikka-discord\node\src\core\command-handler\command-handler.js:185:40)
    at module.exports (C:\Users\vexit\Documents\GitHub\rikka-discord\node\src\core\event-handler\events\message.js:115:46)    
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

and here is my code:

const buttons = require("discord-buttons")(client);
// The button is from discord-buttons examples.
const button = new buttons.MessageButton()
            .setStyle("red")
            .setLabel("My First Button!")
            .setID("click_to_function")
            .setDisabled();

So why ? Please πŸ˜₯😭

timotejroiko commented 3 years ago

you will need to fork discord-buttons and replace all require("discord.js") with require("discord.js-light") in their v12 classes folder, because they are trying to extend the base discord.js classes instead of the already extended discord.js-light classes.

Not sure what else could be done, discord-buttons was not made to be compatible with djs-light.

Vexcited commented 3 years ago

Okay ; Sorry for the troubles, but in fact I made a mistake.

In my command handler I've wrote that

const buttons = require("discord-buttons")(client);

well it was only

const buttons = require("discord-buttons");

The only modification I need to do is to backup the real discord.js package version with this

const { version } = require("discord.js");
const Discord = require("discord.js-light");
Discord.version = version;

Sorry, but thanks too !

DomeQdev commented 3 years ago

@Vexcited please use official discord.js version of buttons. https://discord.js.org/#/docs/main/master/class/MessageButton

Vexcited commented 3 years ago

@DomeQdev ; How do I do that ? Can I have one example please 😭 ?

davipatricio commented 3 years ago

@Vexcited you can see some examples in discord.js guide: https://deploy-preview-674--discordjs-guide.netlify.app/interactions/buttons.html

timotejroiko commented 3 years ago

this is now supported in v4, so im gonna go ahead and close this