Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. Developer API
  2. Sending a message:
  3.  
  4. Discord.Backend.API:Send(
  5. Discord.OOP:New('Message'):SetChannel('Relay'):SetEmbed({
  6. color = 0xe74c3c,
  7. description = 'hello world',
  8. }):ToAPI()
  9. )
  10.  
  11.  
  12. Properties of Message class:
  13.  
  14. Message:SetChannel(string Channel) -- Sets the channel the message should be sent to (Channel should exist in the config)
  15. Message:SetRaw(table Data) - Accepts the raw format for Discord messages, more here: https://discordapp.com/developers/docs/resources/channel#create-message
  16. Message:SetMessage(string Message) -- Sets the message's contents
  17. Message:SetEmbed(table EmbedData) -- Accepts the raw format for Discord embed, more here: https://discordapp.com/developers/docs/resources/channel#embed-object
  18. Message:ToAPI() -- Returns sendable format for my backend
  19.  
  20.  
  21. Creating own commands: (Execution of commands currently restricted only to Relay and Admin channel)
  22.  
  23. Discord:RegisterCommand('command', function(data)
  24. print('command was ran from discord!')
  25. end)
  26.  
  27.  
  28. 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.
  29.  
  30.  
  31. Command data:
  32.  
  33. {
  34. raw = '!command test "argument 2"', -- Raw output of the message invoking the command
  35. channel = 'Relay', -- Channel name the command was ran in - matches the ones in discord_config.lua
  36. command = 'command', -- The command name ran
  37. argstr = 'test "argument 2"', -- Raw argument string received
  38. author = {
  39. id = '150542592172490752', -- Discord User ID of the command invoker
  40. roles = { -- All roles of the command invoker in the guild
  41. {
  42. id = '544087135020515339', -- Discord Role ID
  43. name = 'Admin', -- Discord Role Name
  44. position = 5, -- Discord Role Position from the Discord API
  45. calculatedPosition = 7, -- Discord Role Position in the Discord Role Manager
  46. permissions = 8, -- Discord Permissions Bitfield of the role permissions (https://discordapp.com/developers/docs/topics/permissions)
  47. },
  48. ...
  49. },
  50. hoistRole = '544087135020515339', -- The ID of the highest role the user has, if none - then it is the Guild ID
  51. nickname = 'Trixter', -- The visible name of the command invoker in the Discord guild
  52. },
  53. }
  54.  
  55.  
  56. Hooks
  57.  
  58. Discord_Backend_Connected() -- Called when the realm has successfully connected to the Backend
  59. Discord_ShouldRelay(player Ply, string Text, any Team) -- Return false to prevent the message from being relayed to Discord
  60. Discord_ParseText(string Text, player Ply) -- Return formatted text that should be relayed to Discord
  61. 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