#unable to Get demo working

1 messages · Page 1 of 1 (latest)

uneven halo
#

I'm trying to get the demo working but I don't get any output (besides the version number)
code

using Discord;
using Discord.WebSocket;

namespace bot
{
    public class Program
    {
        private DiscordSocketClient _client;
        private Task Log(LogMessage msg)
        {
            Console.WriteLine(msg.ToString());
            return Task.CompletedTask;
        }
        public static Task Main(string[] args) => new Program().MainAsync();

        public async Task MainAsync()
        {
            _client = new DiscordSocketClient();

            _client.Log += Log;

            var token = File.ReadAllText("token.txt");

            await _client.LoginAsync(TokenType.Bot, token);
            await _client.StartAsync();
            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
    }
}

only output I get

broken sequoia
#

Output looks right to me. You aren't doing anything else there, so what'd you expect the bot to do? You need to bind events to handle things sent from the gateway via discord.

uneven halo
#

I was expecting it to print the message to the console

broken sequoia
#

What message? Did you bind any message received handler? If not, then it won't know what to do with it, therefore nothing.

#

Continue reading the docs, it explains these things 👍

uneven halo
#

ok 👍