Esempio n. 1
0
        public static async Task CreateNoobGate()
        {
            try
            {
                bool clientNotProperlyConnected = true;
                int  failedToGetNoobGateCount   = 0;

                while (clientNotProperlyConnected)
                {
                    Task.Delay(1000).Wait();

                    var noobGateChannel = DiscordContextSeymour.GetNoobGateChannel();

                    if (noobGateChannel != null)
                    {
                        var msgs = await noobGateChannel.GetMessagesAsync(100).FlattenAsync();

                        await noobGateChannel.DeleteMessagesAsync(msgs);

                        string welcome = ConfigManager.GetProperty(PropertyItem.NoobGateMessage);
                        var    noobGateWelcomeMessage = await noobGateChannel.SendMessageAsync(welcome);

                        DiscordContextSeymour.ReAssignNoobGateWelcome(noobGateWelcomeMessage);

                        await noobGateWelcomeMessage.AddReactionAsync(DiscordContextSeymour.GetEmotePommel() as IEmote);

                        clientNotProperlyConnected = false;

                        if (failedToGetNoobGateCount > 0)
                        {
                            var logChannel = DiscordContextSeymour.GetLoggingChannel();
                            await logChannel.SendMessageAsync($"Failed to get NoobGate {failedToGetNoobGateCount} times on startup");
                        }
                    }

                    failedToGetNoobGateCount++;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.GateMessageCreationException, ex);
            }
        }