Deathknife / sourcemod-discord

Discord API for Sourcemod
61 stars 35 forks source link

sourcemod-discord

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

IMPORTANT

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 )

Installation

Optional examples:

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.

Features

API

For full list view discord.inc and take a look at discord_test.sp for examples.

Note

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);

OnChannelMessage

Both Bot and channel are destroyed after it's called.