Recently Klasa (discord.js bot framework) has migrated to it's own Discord API wrapper @klasa/core
instead of using the generic discord.js
.
- Creation of
@klasa/core
gives full customizability to it's core thatdiscord.js
failed to offer. @klasa/core
has High-Level API with Low-Level Performance.- Implements Discord API more directly unlike
discord.js
. - Allows implementation of Custom API Interactions using Actions.
- Sends exactly what it's asked to by your code to the Discord API without any transformations.
- Does not contain over a thousand overloads unlike
discord.js
. It's completely written in TypeScript. - Performance improvements in comparison to
discord.js
.
#klasa-core
is the Discord API Wrapper that replacesdiscord.js
.#klasa-next
is the Klasa version that utilizes@klasa/core
instead ofdiscord.js
#klasa-stable
is the older and outdated Klasa's version that usesdiscord.js
.
@klasa/core
(discord api wrapper): https://dirigeants.github.io/core/klasa
(bot framework): https://dirigeants.github.io/klasa/
<Client>.login(TOKEN)
is now<Client>.connect()
prior to which you will have to define your token to yourClient
by doing<Client>.token = "YOUR TOKEN"
. This offers more safety as it stores the token in a Private Field and does not store it where it can be accessed by the end user.- Colors can now only be used as decimal (i.e.
3093151
) instead of hexadecimal (i.e.#2F329F
). You can also use0x<HEXADECIMAL>
(i.e.0x2F329F
). - More Conventional OOP design, for example it's now
guild.bans.add(<ID>)
andmember.ban()
and notguild.ban(<ID>)
. - Async Iterators have been added:
for await (const [message] of channel.messages.iterate({ idle: 30000 })) {
// Do something with message until there is no message for 30 seconds
}
for await (const [reaction, user] of message.reactions.iterate({ limit: 5 })) {
// Do something with the first 5 reactions/users for the given message
}
- Introducing Builders for Messages, WebHooks, Presence, etc. This means you won't be able to just do
<channel>.send()
like you used to, now you'll have to send aMessage
that was created using theMessageBuilder
and thus the same for things of similar nature. Here's an example of User Presence:
this.client.user.presence.modify(pb => pb // pb an instance of PresenceBuilder
.setGame(gb => gb // gb an instance of PresenceGameBuilder
.setType(ActivityTypes.Listening)
.setName('@BotMention help')
));
klasa
remains almost similar to it's previous versions except...
raplayer dope channel#0001
, kyra#0001
, enkiel#8897
, doge#1234
, StarlitePyro#2691
, AoDude#8676