Added new getting started guide
Thanks @MinnDevelopment for his awesome work on the JDA guide that had no influence here at all.
This commit is contained in:
42
docs/guides/samples/intro/complete.cs
Normal file
42
docs/guides/samples/intro/complete.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MyBot
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
=> new Program().MainAsync().GetAwaiter().GetResult();
|
||||
|
||||
public async Task MainAsync()
|
||||
{
|
||||
var client = new DiscordSocketClient();
|
||||
|
||||
client.Log += Log;
|
||||
client.MessageReceived += MessageReceived;
|
||||
|
||||
string token = "abcdefg..."; // Remember to keep this private!
|
||||
await client.LoginAsync(TokenType.Bot, token);
|
||||
await client.StartAsync();
|
||||
|
||||
// Block this task until the program is closed.
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
|
||||
private async Task MessageReceived(SocketMessage message)
|
||||
{
|
||||
if (message.Content == "!ping")
|
||||
{
|
||||
await message.Channel.SendMessageAsync("Pong!");
|
||||
}
|
||||
}
|
||||
|
||||
private Task Log(LogMessage msg)
|
||||
{
|
||||
Console.WriteLine(msg.ToString());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user