Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Developer API
- Sending a message:
- Discord.Backend.API:Send(
- Discord.OOP:New('Message'):SetChannel('Relay'):SetEmbed({
- color = 0xe74c3c,
- description = 'hello world',
- }):ToAPI()
- )
- Properties of Message class:
- Message:SetChannel(string Channel) -- Sets the channel the message should be sent to (Channel should exist in the config)
- Message:SetRaw(table Data) - Accepts the raw format for Discord messages, more here: https://discordapp.com/developers/docs/resources/channel#create-message
- Message:SetMessage(string Message) -- Sets the message's contents
- Message:SetEmbed(table EmbedData) -- Accepts the raw format for Discord embed, more here: https://discordapp.com/developers/docs/resources/channel#embed-object
- Message:ToAPI() -- Returns sendable format for my backend
- Creating own commands: (Execution of commands currently restricted only to Relay and Admin channel)
- Discord:RegisterCommand('command', function(data)
- print('command was ran from discord!')
- end)
- Discord:RegisterCommand(string Command, function Callback) -- Registers new command that can be executed from Discord. Callback has one argument which returns the command data. More info below.
- Command data:
- {
- raw = '!command test "argument 2"', -- Raw output of the message invoking the command
- channel = 'Relay', -- Channel name the command was ran in - matches the ones in discord_config.lua
- command = 'command', -- The command name ran
- argstr = 'test "argument 2"', -- Raw argument string received
- author = {
- id = '150542592172490752', -- Discord User ID of the command invoker
- roles = { -- All roles of the command invoker in the guild
- {
- id = '544087135020515339', -- Discord Role ID
- name = 'Admin', -- Discord Role Name
- position = 5, -- Discord Role Position from the Discord API
- calculatedPosition = 7, -- Discord Role Position in the Discord Role Manager
- permissions = 8, -- Discord Permissions Bitfield of the role permissions (https://discordapp.com/developers/docs/topics/permissions)
- },
- ...
- },
- hoistRole = '544087135020515339', -- The ID of the highest role the user has, if none - then it is the Guild ID
- nickname = 'Trixter', -- The visible name of the command invoker in the Discord guild
- },
- }
- Hooks
- Discord_Backend_Connected() -- Called when the realm has successfully connected to the Backend
- Discord_ShouldRelay(player Ply, string Text, any Team) -- Return false to prevent the message from being relayed to Discord
- Discord_ParseText(string Text, player Ply) -- Return formatted text that should be relayed to Discord
- Discord_ParseTeam(any Team) -- Return if the PlayerSay team variable actually means that the message is in team chat (some addons use the team variable for indicating different states of the message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement