What is Voyager?
Voyager is a Roblox API wrapper for Discord webhooks.
Why should I use Voyager?
Voyager makes interacting with Discord webhooks much easier, as you not only write less code but the code you do write is much more readable too, this results in a much better developer experience. Voyager also has very good API coverage over Discord’s webhook API, so no matter how niche your use case is, Voyager can most likely help you out!
How can I start using Voyager?
-
First you need a webhook to send requests to. You can follow this short tutorial by Discord on how to set up a webhook.
-
Get the module script.
-
Make sure http requests in Game Settings > Security is enabled.
-
Drag the module into your project and place it in ServerScriptService or ServerStorage.
Code examples
Example 1: Sending a message
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
webhook:execute("Hello, World!")
Example 2: Sending a message with embedded content
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
local embed = require(Voyager.Embed).new("Voyager is really useful!")
webhook:execute(nil, {embed})
Example 3: Sending a message to a thread
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
local optionalExecuteInfo = require(Voyager.OptionalExecuteInfo).new("threadId")
webhook:execute("Nice thread 👌", nil, nil, nil, optionalExecuteInfo)
Example 4: Sending a TTS message
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
local optionalExecuteInfo = require(Voyager.OptionalExecuteInfo).new(nil, true)
webhook:execute("This is a tts message!", nil, nil, nil, optionalExecuteInfo)
Note: Do keep in mind that you have to be in the channel before the message is sent, otherwise it will not play for you.
Example 5: Obtaining a Message object
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
local message, requestInfo = webhook:execute("Hello, World!", nil, false, true)
if requestInfo.success then
print(message.id)
end
Can Voyager do more than just send messeges?
Yes! Voyager can also edit and delete messeges sent by the webhook.
How can I edit a message with Voyager?
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
webhook:editMessage("messageId", "Hello, there!")
Before:
After:
How can I delete a message with Voyager?
local Voyager = path_here.Voyager
local webhook = require(Voyager.Webhook).new("webhookId", "webhookToken")
webhook:deleteMessage("messageId")
With Voyager vs without Voyager
See an example here.
Credit
Huge thanks to @lewisakura for creating and hosting the proxy used in this module. Without them this module wouldn’t have been possible.
Documentation
The full documentation can be found here.
Github
The github can be found here.