DisWebHooks
DisWebHooks - A free and easy to use module script that allows you to manage discord webhooks on the go!
Features:
- Easy to use
- Automatic error catching
- Requests are sent directly to Discord API (v10)
Tutorial
- Enable game http requests (Security section)
- Get script and place into ServerScriptService:
local dishooks = require(game.ServerScriptService.DisWebHooks)
- Get webhook:
local webhook = dishooks.GetWebhook("webhook-url")
- Execute, delete or modify webhook:
-- Send message to webhook channel
local message = require(game.ServerScriptService.DisWebHooks.Message)
local msg = message.new("Hello, World!")
webhook:SendMessage(msg)
-- Modify webhook
local body = {
["name"] = "Rbx WebHook"
}
webhook:Modify(body)
-- Delete webhook
webhook:Delete()
Example
Simple chat-logger server script:
local dishooks = require(game.ServerScriptService.DisWebHooks)
local message = require(game.ServerScriptService.DisWebHooks.Message)
local embed = require(game.ServerScriptService.DisWebHooks.Embed)
local webhook = nil
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(content, _r)
if webhook ~= nil then
local msg = message.new()
msg:SetContent(content)
msg:SetUsername(plr.Name)
webhook:SendMessage(msg)
end
end)
end)
webhook = dishooks.GetWebhook("webhook-url")
Embed-Example
Chat-logger embed edition:
local dishooks = require(game.ServerScriptService.DisWebHooks)
local message = require(game.ServerScriptService.DisWebHooks.Message)
local embed = require(game.ServerScriptService.DisWebHooks.Embed)
local webhook = nil
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(content, _r)
if webhook ~= nil then
local msg = message.new()
msg:SetUsername(plr.Name)
local emb = embed.new()
emb:SetTitle("Message sent!")
emb:SetDescription("Content: "..content)
emb:SetColor(Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255)))
emb:SetAuthor(plr.Name)
msg:AddEmbed(emb)
webhook:SendMessage(msg)
end
end)
end)
webhook = dishooks.GetWebhook("webhook-url")
Documentation
DisWebHooks
.GetWebhook(id: string, token: string): Webhook
Webhook
:SendMessage(msg: {}, thread_id: string?) - Send a message to a webhook channel
:Modify(body: {}): boolean - Change the name or avatar of the webhook. Returns whether the action was successful or not
:Delete(reason: string?) - Delete webhook.
:GetId(): string - Returns webhook ID
:GetToken(): string - Returns webhook token
:GetType(): string - Returns webhook type
:GetGuildId(): string - The guild id this webhook is for, if any
:GetChannelId(): string - The channel id this webhook is for, if any
:GetName(): string - The default name of the webhook
:GetAvatarUrl(): string - Returns webhook avatar url
Message
:SetContent(content: string) - set message content
:SetUsername(username: string) - override the default username of the webhook
:SetAvatarUrl(avatarUrl: string) - override the default avatar of the webhook
:SetTts(tts: boolean) - true if this is a TTS (TextToSpeech) message
:AddEmbed(embed: {}) - add embed to the message
:SetThreadName(thread_name: string) - name of thread to create (requires the webhook channel to be a forum or media channel)
:ApplyTag(tagId: string) - add tag to apply to the thread (requires the webhook channel to be a forum or media channel)
Embed
:SetTitle(title: string) - set title of embed
:SetDescription(description: string) - set description of embed
:SetFooter(text: string, iconUrl: string?) - set footer information
:SetImageUrl(url: string) - set embed big image
:SetThumbnailUrl(url: string) - set small right-top embed image
:SetAuthor(name: string, avatarUrl: string?, url: string?) - set author information
:AddField(name: string, val: string, inline: boolean?)
:SetColor(color: Color3) - set color of embed