Discord API for Sourcemod. There's a lot more to add. Changes will be happening that will break existing plugins, sorry. Still a bit messy
Before you are able to send messages, you have to create a websocket connection with the bot atleast once. Simply, do this: http://scooterx3.net/2016-05-25/discord-bot.html
(Or paste this into browser -> console: http://pastebin.com/3g2HbTjY )
- Snag this JSON library and place it in your includes folder
- Fetch SteamWorks, put SteamWorks.inc in your includes and SteamWorks.dll in /sourcemod/extensions
- Put discord.inc and /discord in your includes folder
- Compile discord_api.sp and put it in your /sourcemod/plugins folder
Optional examples:
- Edit the .sp by replacing
<Bot Token>
with your bot token. - Compile and place in /sourcemod/plugins
Bot Token can be obtained from:
https://discord.com/developers/applications/me
Create a new user and turn into bot account, reveal Token and copy.
- List all guilds
- List all Channels for guilds
- Send Messages to Channel
- Listen for messages for Channel
For full list view discord.inc
and take a look at discord_test.sp
for examples.
DiscordBot and DiscordChannel are both Handles. Everytime DiscordBot is passed, it's the same Handle to the Bot. This should not be closed unless you don't need that Bot anymore. DiscordChannel are handles to the Channel. Everytime Channel is passed the handle is closed after. If you need to keep the Channel Handle, Clone it. E.g
DiscordChannel newChannel = CloneHandle(Channel);
Both Bot and channel are destroyed after it's called.