DisBot For Discord Bots

I have created this module [OPEN SOURCE] that will allow you to use Discord bots from Roblox, this module already brings some functions such as sending messages, embeds, react messages, reply messages, kick or ban a member of a server, and send direct messages (DM). (this module does not use discordia)

NOTE: the bot does not need to be online.

This module is very easy to setup, here are the steps:

Module Link: DisBot Module

-Step1:
Create a script.

-Step2:
Require the module in the script:

local DisBot = require(13165754449)

-Step3:
You have to set the Token of the bot, and the Id of a server where the bot is located:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

and that’s it!

-SEND MESSAGE:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local channelId = "ChannelIdGoesHere" --> where you want to send the message.
local message = "this is the message"

DisBot:Message("BotName", channelId, message)

-SEND EMBED:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local channelId = "ChannelIdGoesHere" --> where you want to send the embed.
local embedExample = {

	title = "Title of the Embed",
	description = "Description of the Embed",
	color = 65280, -- green color
	thumbnail = {
		url = "https://www.roblox.com/asset-thumbnail/image?assetId=102611803"
	},
	author = {
		name = "Author of the Embed",
		url = "https://www.roblox.com/users/123456/profile"
	},
	footer = {
		text = "Footer Text",
		icon_url = "https://www.roblox.com/asset-thumbnail/image?assetId=102611803"
	},
	fields = {
		{
			name = "Field 1",
			value = "Value of Field 1"
		},
		{
			name = "Field 2",
			value = "Value of Field 2"
		}
	}
}

DisBot:Embed("BotName", channelId, embedExample)

-REACT TO MESSAGE:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local channelId = "ChannelIdGoesHere" --> where you want to send the embed.
local messageId = "MessageIdGoesHere" --> which message you want to react
local emoji = "Emoji or emoji id (for nitro emojis)"

DisBot:ReactToMessage("BotName", channelId, messageId, emoji)

-KICK OR BAN MEMBER:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local memberId = "MemberIdGoesHere" --> member to kick or ban

---[Kick]---
DisBot:KickMember("BotName", memberId)
---[Ban]---
DisBot:BanMember("BotName", memberId)

-DIRECT MESSAGE (DM):

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local embedExample = {

	title = "Title of the Embed",
	description = "Description of the Embed",
	color = 65280, -- green color
	thumbnail = {
		url = "https://www.roblox.com/asset-thumbnail/image?assetId=102611803"
	},
	author = {
		name = "Author of the Embed",
		url = "https://www.roblox.com/users/123456/profile"
	},
	footer = {
		text = "Footer Text",
		icon_url = "https://www.roblox.com/asset-thumbnail/image?assetId=102611803"
	},
	fields = {
		{
			name = "Field 1",
			value = "Value of Field 1"
		},
		{
			name = "Field 2",
			value = "Value of Field 2"
		}
	}
}

local ExampleArgs = {

["BotName"] = "BotName", --1st *
["UserId"] = "UserIdGoesHere", --2th *
["Message"] = "MessageGoesHere",
["Embed"] = embedExample,

}

local function SendDM(Channel:string, Args:{})
	---[DM | Message Example]---
	DisBot:Message(Args["BotName"], Channel, Args["Message"])
	---[DM | Embed Example]---
	DisBot:Embed(Args["BotName"], Channel, Args["Embed"])
	
end

DisBot:DM("BotName", ExampleArgs, SendDM)

-REPLY MESSAGES:

local DisBot = require(13165754449)
DisBot:SetBot("BotName", "BotTokenGoesHere")
DisBot:SetServer("ServerIdGoesHere")

local replyMessage = "This is the message" --> the reply message
local channelId = "ChannelIdGoesHere" --> where is the message to reply
local messageId = "MessageIdGoesHere" --> message to reply id

DisBot:ReplyMessage("BotName", replyMessage, channelId, messageId)

UPDATE#2: Now you can add more than one Discord Bot and use it with just one module or module id.

13 Likes

Thanks for making this! I was looking for resources to help me.

1 Like

I didn’t know you could go this far with luau and discord bot, thought this was a generic webbook.

1 Like

Woah, are we getting discord.luau? :eyes: Although since your module needs to be required, I’m concerned over where the bot token goes. But other than that, this has blown my mind. Why not use up some extra roblox resources for your discord bot while the game is running :laughing:

You can import the module from your inventory if you want to pin the module and avoid any unwanted updates.

1 Like

It is better to use the id of the module (for the moment), because the module is equivalent to a bot, so if for example you wanted to use some of these functions with more than one Discord Bot it is better to require the id of the module than to add the same module more at once just for using these functions with more than one bot, I’m going to update this so that with one module you can use these functions to more than one Discord Bot. (And also because you would get the most updated version of the module, that would mean access to more features to use your Discord Bot through Roblox Studio)

There is no purpose for automatic feature updates if users will not be using the features or implementing them immediately; therefore, users would not be heavily impacted by importing the module at its current state rather than requiring it by id. If a user has the module in his/her inventory, that would make manually updating much easier. When dealing with sensitive information like a bot token, it is much better to import the module because you will know where your bot token is going.

1 Like

Would much rather download the module and require that instead. It would be unsafe for developers to require a black box and send a confidential API key through it.

3 Likes

This looks really good, hidden gem. One thing I would add is that when the disbot:Message() / disbot:Embed() is fired it returns the message data, so that reactions or replys can be added on to the message sent. :smile:

there is a function to reply and react to a message however i will keep that in mind

right, but you need the message id. which can be found in the data returned from :postAsync() or :requestAsync()

I recommend uploading your code to GitHub so others can contribute to the module.

Uploading to GitHub allows for an easy way to suggest ideas and submit changes.

1 Like

A few types I made, this would make it easier to for example make embeds inside of roblox.
Though honestly I wasn’t quite sure what they meant with the type “snowflake”, nor did I know how to add an int type nor ISO8601.

type embed = {
	["title"]: string?,
	["type"]: "rich" | "image" | "video" | "gifv" | "article" | "link",
	["description"]: string?,
	["url"]: string?,
	["timestamp"]: any?, -- ISO8601 
	["color"]: any?, -- INT
	["footer"]: {
		["text"]: string,
		["icon_url"]: string?,
		["proxy_icon_url"]: string?
	}?,
	["image"]: {
		["url"]: string,
		["proxy_url"]: string?,
		["height"]: number?, -- INT
		["width"]: number? -- INT
	}?,
	["thumbnail"]: {
		["url"]: string,
		["proxy_url"]: string?,
		["height"]: number?, -- INT
		["width"]: number? -- INT
	}?,
	["video"]: {
		["url"]: string?,
		["proxy_url"]: string?,
		["height"]: number?, -- INT
		["width"]: number? -- INT
	}?,
	["provider"]: {
		["name"]: string?,
		["url"]: string?
	}?,
	["author"]: {
		["name"]: string?,
		["url"]: string?,
		["icon_url"]: string?,
		["proxy_icon_url"]: string?
	}?,
	["fields"]: {[number]: {
		["name"]: string,
		["value"]: string,
		["inline"]: boolean?
	}}?
}
type activity = {
	["name"]: string,
	["type"]: number, -- INT, 0: Playing {name}, 1: Streaming {details} (https://twitch.tv/ or https://youtube.com/),
	-- 2: Listening to {name}, 3: Watching {name}, 4: {emoji} {name}, 5: Competing in {name}
	["url"]: string?, -- type = 1
	["created_at"]: number, -- UNIX, INT
	["timestamps"]: {
		["start"]: number?, 
		["end"]: number?
	}?,
	["application_id"]: any?,
	["details"]: string?,
	["state"]: string?,
	["emoji"]: {
		["name"]: string, 
		["id"]: any?, 
		["animated"]: boolean?
	}?,
	["party"]: {
		["id"]: string?,
		["size"]: {
			["current_size"]: number, 
			["max_size"]: number
		}?
	}?,
	["assets"]: {
		["large_image"]: string?, 
		["large_text"]: string?, 
		["small_image"]: string?,
		["small_text"]: string?
	},
	["secrets"]: {
		["join"]: string?,
		["spectate"]: string?,
		["match"]: string?
	}?,
	["instance"]: boolean,
	["flags"]: number, -- INT
	["buttons"]: {[number]: {
		["label"]: string,
		["url"]: string
	}?}
}
type presence = { -- Gateway update precense
	["since"]: number, -- INT
	["activities"]: {[number]: activity?},
	["status"]: "online" | "dnd" | "idle" | "invisible" | "offline",
	["afk"]: boolean
}

For example, by using:

local myEmbed: embed = {...}

it’ll give you suggestions on what should be added.

1 Like

Sorry for bumping. But is it possible to make ephemeral messages with DisBot?