Files
Discord.Net/docs/samples/events.cs
Christopher F 3bc91838e9 Documentation updates:
global: Modified the unicode in |stub| to be compatible with sphinx. Still appears as a wrench in the browser.

events: added information for events, and a list of events, as well as their arg paramater. Still marked as 'WIP', as I feel my documentation was a bit lacking

permissions: added information for channel\server permissions, dual channel permissions, and roles. need to update with bits at some point.
2015-11-20 18:06:49 -05:00

27 lines
726 B
C#

class Program
{
private static DiscordBotClient _client;
static void Main(string[] args)
{
var client = new DiscordClient();
// Handle Events using Lambdas
client.MessageCreated += (s, e) =>
{
if (!e.Message.IsAuthor)
await client.SendMessage(e.Message.ChannelId, "foo");
}
// Handle Events using Event Handlers
EventHandler<MessageEventArgs> handler = new EventHandler<MessageEventArgs>(HandleMessageCreated);
client.MessageCreated += handler;
}
// NOTE: When using this method, 'client' must be accessible from outside the Main function.
static void HandleMessageCreated(object sender, EventArgs e)
{
if (!e.Message.IsAuthor)
await client.SendMessage(e.Message.ChannelId, "foo");
}
}