예제 #1
0
 public static async Task EchoAndReply(this ISocketMessageChannel channel, string msg)
 {
     // Announce it in the channel the command was entered only if it's not already an echo channel.
     EchoUtil.Echo(msg);
     if (!EchoModule.IsEchoChannel(channel))
     {
         await channel.SendMessageAsync(msg).ConfigureAwait(false);
     }
 }
예제 #2
0
        public async Task ToggleQueueTradeAsync()
        {
            var state = Info.ToggleQueue();
            var msg   = state
                ? "Users are now able to join the trade queue."
                : "Changed queue settings: **Users CANNOT join the queue until it is turned back on.**";

            // Announce it in the channel the command was entered only if it's not already an echo channel.
            if (!EchoModule.IsEchoChannel(Context.Channel))
            {
                await ReplyAsync(msg).ConfigureAwait(false);
            }
            EchoUtil.Echo(msg);
        }
예제 #3
0
        public async Task MainAsync(string apiToken, CancellationToken token)
        {
            // Centralize the logic for commands into a separate method.
            await InitCommands().ConfigureAwait(false);

            // Login and connect.
            await _client.LoginAsync(TokenType.Bot, apiToken).ConfigureAwait(false);

            await _client.StartAsync().ConfigureAwait(false);

            // Restore Echoes
            await Task.Delay(5_000, token).ConfigureAwait(false);

            EchoModule.RestoreChannels(_client);

            // Restore Logging
            await Task.Delay(5_000, token).ConfigureAwait(false);

            LogModule.RestoreLogging(_client);
            TradeStartModule.RestoreTradeStarting(_client);

            var game = SysCordInstance.Settings.BotGameStatus;

            if (!string.IsNullOrWhiteSpace(game))
            {
                string gameText = $"{Hub.Config.Discord.BotGameStatus.Replace("{0}", $"Queue is Empty")}";
                await _client.SetGameAsync(gameText).ConfigureAwait(false);
            }

            var app = await _client.GetApplicationInfoAsync().ConfigureAwait(false);

            SysCordInstance.Manager.Owner = app.Owner.Id;

            // Wait infinitely so your bot actually stays connected.
            await MonitorStatusAsync(token).ConfigureAwait(false);
        }