Exemplo n.º 1
0
        private async Task RunBotAsync()
        {
            _client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                ExclusiveBulkDelete = true,
                DefaultRetryMode    = RetryMode.AlwaysRetry
            });

            _commands = new CommandService();
            _services = new ServiceCollection()
                        .AddSingleton(_client)
                        .AddSingleton(_commands)
                        .BuildServiceProvider();

            _client.Log            += _client_Log;
            _client.UserJoined     += _client_UserJoined;
            _client.MessageDeleted += _client_MessageDeleted;

            var token = GetToken();

            await RegisterCommandsAsync();

            await _client.LoginAsync(TokenType.Bot, token);

            await _client.SetGameAsync("Everyone", "", ActivityType.Watching);

            await _client.StartAsync();

            var serverTimer = new ServerTimerService();

            Console.WriteLine(String.Format("{0}\t Gateway \tServer Started", DateTime.Now.ToLongTimeString()));
            await Task.Delay(-1);
        }
Exemplo n.º 2
0
        public async Task Uptime()
        {
            var uptime = ServerTimerService.GetServerUptime();
            var sb     = new StringBuilder();

            sb.AppendLine(String.Format("Uptime : {0}", uptime));
            var embed = EmbedBuilderHelper.BuildEmbed("Server Uptime", sb.ToString(), DateTime.Now.ToLongTimeString(), "blue");
            await Context.Channel.SendMessageAsync(null, false, embed);
        }