30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
class Program
|
|
{
|
|
private static DiscordBotClient _client;
|
|
static void Main(string[] args)
|
|
{
|
|
var client = new DiscordClient();
|
|
|
|
//Log some info to console
|
|
client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
|
|
|
|
//Echo any message received, provided it didn't come from us
|
|
client.MessageCreated += async (s, e) =>
|
|
{
|
|
if (!e.Message.IsAuthor)
|
|
await client.SendMessage(e.Message.ChannelId, e.Message.Text);
|
|
};
|
|
|
|
//Convert our sync method to an async one and blocks this function until the client disconnects
|
|
client.Run(async () =>
|
|
{
|
|
//Connect to the Discord server usinotng our email and password
|
|
await client.Connect("discordtest@email.com", "Password123");
|
|
|
|
//If we are not a member of any server, use our invite code
|
|
if (!client.Servers.Any())
|
|
await client.AcceptInvite("aaabbbcccdddeee");
|
|
});
|
|
}
|
|
}
|