Migrating from Discord.JS
A word of warning
Before we begin, please note that Revolt does not support interactions or slash commands. This guide will only help for bots that use message-based commands and such. While we may add support for slash commands in the future, for now message-based commands are the only option for making Revolt bots.
The basics
When running your bot, make sure to pass --experimental-specifier-resolution=node
as a Node flag (for example, node --experimental-specifier-resolution=node index.js
). Revolt.js will not work if you do not pass this flag.
Unlike Discord, Revolt does not have intents and you do not need to specify them when creating a client. You should remove any code that specifies any intents.
client.once("ready", () => { code })
should be replaced withclient.on("ready", async () => { code }
.client.login(botToken)
should be replaced withclient.loginBot(botToken)
(or, for selfbots,client.useExistingSession(sessionToken, user_id: "", name: "")
).client.guilds
should be replaced withclient.servers
.
Messages
- Unlike Discord.JS, messages may sometimes be
SystemMessage
s. As a result, thecontent
property may be null, so you'll need to handle this - either by ignoring messages without any content (like this):
if (!message.content) return;
...or by handling them separately (for example, if you're making a logging bot and want to log these events).
Messages are not guaranteed to have channels. You'll mostly see this with
SystemMessages
. To prevent any issues, use optional chaining like this:
message.channel?.xyz
- On top of this, Revolt.js's
.send
function is.sendMessage
-message.channel.send
should be replaced withmessage.channel?.sendMessage
.
Embeds
- Embeds do not have fields - you should use bold text and newlines to acheive a similar effect.