Merge branch 'master'

This commit is contained in:
RogueException
2015-11-25 01:47:15 -04:00

View File

@@ -1,29 +1,28 @@
class Program class Program
{ {
private static DiscordBotClient _client; static void Main(string[] args)
static void Main(string[] args) {
{ var client = new DiscordClient();
var client = new DiscordClient();
//Display all log messages in the console
//Log some info to console
client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}"); client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
//Echo any message received, provided it didn't come from us //Echo back any message received, provided it didn't come from the bot itself
client.MessageCreated += async (s, e) => client.MessageReceived += async (s, e) =>
{ {
if (!e.Message.IsAuthor) if (!e.Message.IsAuthor)
await client.SendMessage(e.Message.ChannelId, e.Message.Text); await client.SendMessage(e.Channel, e.Message.Text);
}; };
//Convert our sync method to an async one and blocks this function until the client disconnects //Convert our sync method to an async one and block the Main function until the bot disconnects
client.Run(async () => client.Run(async () =>
{ {
//Connect to the Discord server usinotng our email and password //Connect to the Discord server using our email and password
await client.Connect("discordtest@email.com", "Password123"); await client.Connect("discordtest@email.com", "Password123");
//If we are not a member of any server, use our invite code //If we are not a member of any server, use our invite code (made beforehand in the official Discord Client)
if (!client.Servers.Any()) if (!client.AllServers.Any())
await client.AcceptInvite("aaabbbcccdddeee"); await client.AcceptInvite(client.GetInvite("aaabbbcccdddeee"));
}); });
} }
} }