예제 #1
0
        /// <summary>
        /// Helper Function to simplify asking for a channel
        /// </summary>
        /// <returns>Resulting Channel object from the Users input</returns>
        private async Task <DiscordChannel> _RequestNotificationChannel(DiscordGuild discordGuild)
        {
            var messageEmbedFooter = new EmbedFooterBuilder()
                                     .WithText("Please mention the channel with the # prefix");
            var messageEmbed = new EmbedBuilder()
                               .WithColor(Color.DarkPurple)
                               .WithDescription($"Please mention the Discord Channel you would like to start or stop a notification for.\nEx: {MentionUtils.MentionChannel(Context.Channel.Id)}")
                               .WithFooter(messageEmbedFooter)
                               .Build();

            var questionMessage = await ReplyAsync(message : $"{Context.Message.Author.Mention}", embed : messageEmbed);

            var responseMessage = await NextMessageAsync(timeout : Defaults.MessageTimeout);

            IGuildChannel guildChannel = responseMessage.MentionedChannels.FirstOrDefault();

            await _DeleteMessage(questionMessage);
            await _DeleteMessage(responseMessage);

            DiscordChannel discordChannel = null;

            if (guildChannel != null)
            {
                discordChannel = new DiscordChannel
                {
                    DiscordGuild = discordGuild,
                    DiscordId    = guildChannel.Id,
                    Name         = guildChannel.Name
                };
                await _work.ChannelRepository.AddOrUpdateAsync(discordChannel, i => i.DiscordGuild == discordGuild && i.DiscordId == guildChannel.Id);

                discordChannel = await _work.ChannelRepository.SingleOrDefaultAsync(c => c.DiscordId == guildChannel.Id);
            }

            return(discordChannel);
        }
예제 #2
0
        public async Task MessageReceivedAsync(SocketMessage rawMessage)
        {
            // Ignore system messages, or messages from other bots
            if (rawMessage is not SocketUserMessage message)
            {
                return;
            }
            if (message.Source != MessageSource.User)
            {
                return;
            }

            if (Program.serverConfig.blacklistWords.Any(message.Content.ToLower().Contains))
            {
                await message.DeleteAsync();

                return;
            }

            if (Program.serverConfig.whiteList == null || Program.serverConfig.whiteList.All(x => x != message.Author.Id))
            {
                if (!Program.serverConfig.publicChannel.Contains(message.Channel.Id)) // Special channel that does not follow the normal rules
                {
                    if (Program.serverConfig.videoChannel != 0)
                    {
                        if (Program.serverConfig.videoList.Any(message.Content.ToLower().Contains) && message.Channel.Id == Program.serverConfig.videoChannel)
                        {
                            if (!freeMsgList.Contains(message.Author))
                            {
                                freeMsgList.Add(message.Author);
                            }

                            Emoji thumbsUp = new Emoji("👍");
                            await message.AddReactionAsync(thumbsUp);
                        }
                        else if (Program.serverConfig.videoList.Any(message.Content.ToLower().Contains) && message.Channel.Id != Program.serverConfig.videoChannel)
                        {
                            if (!freeMsgList.Contains(message.Author))
                            {
                                freeMsgList.Add(message.Author);
                            }

                            ulong videoChan = Program.serverConfig.videoChannel;
                            await message.DeleteAsync();

                            await message.Channel.SendMessageAsync("Please don't post videos in this channel. I have posted it for you in " + MentionUtils.MentionChannel(videoChan));

                            var cchannel    = (message.Channel as SocketGuildChannel)?.Guild;
                            var textChannel = (ISocketMessageChannel)cchannel.GetChannel(videoChan);
                            await textChannel.SendMessageAsync(message + " Posted by: " + message.Author.Mention);
                        }
                        else if (!Program.serverConfig.videoList.Any(message.Content.ToLower().Contains) && message.Channel.Id == Program.serverConfig.videoChannel)
                        {
                            if (freeMsgList.Contains(message.Author))
                            {
                                freeMsgList.Remove(message.Author);
                            }
                            else
                            {
                                await message.DeleteAsync();

                                await message.Author.SendMessageAsync("Please only post videos in the video channel");
                            }
                        }
                    }
                }
            }

            var context = new ShardedCommandContext(_discord, message);

            foreach (var duel in Program.awaitingDuels)
            {
                if (duel.TimeStamp < DateTime.Now.AddMinutes(-1))
                {
                    Program.awaitingDuels.Remove(duel);
                }
            }

            if (Program.awaitingDuels.Select(x => x.Challenge).Contains(rawMessage.Author.Id) && rawMessage.Content.ToLower().Split(" ").Contains("yes"))
            {
                var duel       = Program.awaitingDuels.Last(x => x.Challenge == rawMessage.Author.Id);
                var challenger = duel.Challenger;
                await context.Channel
                .SendMessageAsync($"{rawMessage.Author.Mention} has accepted {MentionUtils.MentionUser(challenger)}s call to duel. Be ready to shoot (🔫).");

                Program.awaitingDuels.Remove(duel);
                _ = CountDownInChat(context.Channel, challenger, rawMessage.Author.Id, duel.BetAmount);
            }

            if ((Program.activeDuels.Select(x => x.Challenge).Contains(rawMessage.Author.Id) ||
                 Program.activeDuels.Select(x => x.Challenger).Contains(rawMessage.Author.Id)) &&
                rawMessage.Content.ToLower().Split(" ").Contains("🔫"))
            {
                var duel  = Program.activeDuels.Last(x => x.Challenge == rawMessage.Author.Id || x.Challenger == rawMessage.Author.Id);
                var loser = duel.Challenge == rawMessage.Author.Id ? duel.Challenger : duel.Challenge;
                await context.Channel.SendMessageAsync($"{rawMessage.Author.Mention} has won {duel.BetAmount.ToString("n0", nfi)} of {MentionUtils.MentionUser(loser)} gold");

                Program.activeDuels.Remove(duel);
                var da = new DataAccess(new DatabaseContext());
                var bl = new MarvBotBusinessLayer(da);
                await bl.SaveGold(rawMessage.Author, context.Guild, duel.BetAmount);

                await bl.SaveGold(context.Guild.GetUser(loser), context.Guild, -duel.BetAmount);

                await da.SetDuel(duel.Challenger, duel.Challenge, rawMessage.Author.Id, duel.BetAmount);
            }

            // This value holds the offset where the prefix ends
            var argPos = 0;

            if (!message.HasCharPrefix(prefix, ref argPos) && !message.HasMentionPrefix(_discord.CurrentUser, ref argPos))
            {
                return;
            }

            var result = await _commands.ExecuteAsync(context, argPos, _services);

            if (result.Error.HasValue)
            {
                await context.Channel.SendMessageAsync(result.ToString());
            }
        }
예제 #3
0
        public async Task <string> Follow(string user)
        {
            User osuUser = await OsuApi.GetUser.WithUser(user).Result();

            if (user == null)
            {
                return("User not found!");
            }

            if (LatestUpdate.ContainsKey(osuUser.Username))
            {
                return("User already on record.");
            }

            UpdateUser(osuUser.Username, new DateTime(0));

            return($"{osuUser.Username} has been added! Any ranked score {osuUser.Username} sets will show up in {MentionUtils.MentionChannel(OsuChannel.Id)}");
        }
예제 #4
0
        /// <inheritdoc />
        public async Task CollectData(IEmote countedEmote, ISocketMessageChannel collectionChannel, ISocketMessageChannel logChannel, IEnumerable <IRole> roleFilter)
        {
            _authorizationService.RequireClaims(AuthorizationClaim.PopularityContestCount);

            (var messages, var logMessage) = await GetMessagesInChannel(collectionChannel, logChannel);

            var roleIds = roleFilter.Select(d => d.Id).ToArray();

            //Get the last message from each user that has more than 0 reactions, at least one reaction of the kind
            //we're looking for, where the user joined the server before the contest message was sent (10/06/2018 8:41pm UTC),
            //and, if the role filter is specified, has one of those roles
            var lastMessages = messages
                               .Where(d => d.Reactions.Count > 0)
                               .Where(d =>
            {
                if (!(d.Author is IGuildUser msgAuthor))
                {
                    return(false);
                }
                if (!UserIsOldEnough(msgAuthor))
                {
                    return(false);
                }
                if (roleFilter == null || roleFilter.Count() == 0)
                {
                    return(true);
                }

                return(msgAuthor.RoleIds.Intersect(roleIds).Any());
            })
                               .OrderByDescending(d => d.CreatedAt)
                               .GroupBy(d => d.Author)
                               .Select(d => d.First());

            //Take the last message from each user, ordered by reaction count, and take up to the top 3 entries
            var mostReactedMessages = lastMessages
                                      .Where(Message => Message.Reactions.ContainsKey(countedEmote))
                                      .Select(Message => (Message, Message.Reactions[countedEmote].ReactionCount))
                                      .OrderByDescending(d => d.ReactionCount)
                                      .Take(3);

            if (mostReactedMessages == null || mostReactedMessages.Count() == 0)
            {
                await logChannel.SendMessageAsync
                (
                    "Uh oh, we didn't find any messages that matched your criteria.",
                    embed : new EmbedBuilder()
                    .AddInlineField("Channel", MentionUtils.MentionChannel(collectionChannel.Id))
                    .AddInlineField("Emoji", countedEmote)
                    .AddInlineField("Roles", roleFilter.Any() ? roleFilter.Select(d => d.Name).Humanize() : "No Filter")
                );

                return;
            }

            string paste = await UploadLog(logMessage, countedEmote, lastMessages);

            bool isMultiple = mostReactedMessages.Count() > 1;

            var embed = new EmbedBuilder()
                        .WithTitle($"Counting complete!")
                        .WithDescription($"Out of **{lastMessages.Count()}** entries, the top {mostReactedMessages.Count()} messages with the most {countedEmote} reactions " +
                                         (isMultiple ? "are..." : "is..."))
                        .WithColor(new Color(0, 200, 0))
                        .WithFooter($"See all entries here: {paste}");

            int position = 1;

            foreach ((var message, var reactionCount) in mostReactedMessages)
            {
                var    author = message.Author;
                string emoji  = "";

                switch (position)
                {
                case 1:
                    emoji = "🥇";
                    break;

                case 2:
                    emoji = "🥈";
                    break;

                case 3:
                    emoji = "🥉";
                    break;

                default:
                    emoji = "🏅";
                    break;
                }

                embed.AddField($"{emoji} With **{reactionCount}** votes",
                               $"[{author.Username}#{author.Discriminator}! (`{author.Id}`)]({message.GetMessageLink()})");

                position++;
            }

            var mostReactionsOverall = lastMessages
                                       .Select(Message => new { Message, OverallCount = Message.Reactions.Values.Sum(r => r.ReactionCount) })
                                       .OrderByDescending(d => d.OverallCount)
                                       .First();

            var mostAuthor = mostReactionsOverall.Message.Author;

            embed.AddField($"Also, the message with the most reactions overall, with a total of **{mostReactionsOverall.OverallCount}**, is...",
                           $"[{mostAuthor.Username}#{mostAuthor.Discriminator}! (`{mostAuthor.Id}`)]({mostReactionsOverall.Message.GetMessageLink()})");

            await logMessage.ModifyAsync(prop => prop.Embed = embed.Build());
        }
        public async Task <RuntimeResult> MoveRoleplayIntoChannelAsync(string newName, params IGuildUser[] participants)
        {
            if (!(this.Context.User is IGuildUser guildUser))
            {
                return(RuntimeCommandResult.FromError("The current user isn't a guild user."));
            }

            var createRoleplayAsync = await _discordRoleplays.CreateRoleplayAsync
                                      (
                guildUser,
                newName,
                "No summary set.",
                false,
                true
                                      );

            if (!createRoleplayAsync.IsSuccess)
            {
                return(createRoleplayAsync.ToRuntimeResult());
            }

            var roleplay = createRoleplayAsync.Entity;

            foreach (var participant in participants)
            {
                if (participant == this.Context.User)
                {
                    // Already added
                    continue;
                }

                var addParticipantAsync = await _discordRoleplays.AddUserToRoleplayAsync(roleplay, participant);

                if (addParticipantAsync.IsSuccess)
                {
                    continue;
                }

                var message =
                    $"I couldn't add {participant.Mention} to the roleplay ({addParticipantAsync.ErrorReason}. " +
                    $"Please try to invite them manually.";

                await _feedback.SendWarningAsync
                (
                    this.Context,
                    message
                );
            }

            var participantMessages = new List <IMessage>();

            // Copy the last messages from the participants
            foreach (var participant in participants)
            {
                // Find the last message in the current channel from the user
                var channel      = this.Context.Channel;
                var messageBatch = await channel.GetMessagesAsync(this.Context.Message, Direction.Before)
                                   .FlattenAsync();

                foreach (var message in messageBatch)
                {
                    if (message.Author != participant)
                    {
                        continue;
                    }

                    participantMessages.Add(message);
                    break;
                }
            }

            var getDedicatedChannel = await _dedicatedChannels.GetDedicatedChannelAsync(this.Context.Guild, roleplay);

            if (!getDedicatedChannel.IsSuccess)
            {
                return(getDedicatedChannel.ToRuntimeResult());
            }

            var dedicatedChannel = getDedicatedChannel.Entity;

            foreach (var participantMessage in participantMessages.OrderByDescending(m => m.Timestamp))
            {
                var messageLink = participantMessage.GetJumpUrl();
                await dedicatedChannel.SendMessageAsync(messageLink);
            }

            var startRoleplayAsync = await _discordRoleplays.StartRoleplayAsync
                                     (
                (ITextChannel)this.Context.Channel,
                roleplay
                                     );

            if (!startRoleplayAsync.IsSuccess)
            {
                return(startRoleplayAsync.ToRuntimeResult());
            }

            var joinedUsers    = roleplay.JoinedUsers.Select(async p => await this.Context.Client.GetUserAsync((ulong)p.User.DiscordID));
            var joinedMentions = joinedUsers.Select(async u => (await u).Mention);

            var participantList = (await Task.WhenAll(joinedMentions)).Humanize();
            await dedicatedChannel.SendMessageAsync($"Calling {participantList}!");

            return(RuntimeCommandResult.FromSuccess
                   (
                       $"All done! Your roleplay is now available in {MentionUtils.MentionChannel(dedicatedChannel.Id)}."
                   ));
        }
예제 #6
0
 public static string MentionChannel(this ulong id) => MentionUtils.MentionChannel(id);
예제 #7
0
        private async Task PerformPurge(
            SocketUser sender,
            SocketGuildUser user, // May be null
            string timeString,
            string reason = null)
        {
            if (Util.TryParseHuman(timeString, out TimeSpan time) == false)
            {
                await this.ReplyAsync($"Invalid time: `{timeString}`.");

                return;
            }

            // Clamp the time at ten days (avoid old delete errors)
            if (time.TotalSeconds > 864000)
            {
                time = TimeSpan.FromDays(10);
            }

            // Gather the messages for purging
            var cutoff   = this.Context.Message.Timestamp - time;
            var messages =
                await this.Context.Channel.GetMessagesAsync(MAX_PURGE).Flatten();

            List <IMessage> filtered = new List <IMessage>();

            // Perform the bulk delete
            foreach (var msg in messages)
            {
                if (msg.Timestamp > cutoff)
                {
                    if ((user == null) || (msg.Author.Id == user.Id))
                    {
                        // Ignore the message for pingdeletes
                        this.message.IgnoreMessage(msg.Id);
                        filtered.Add(msg);
                    }
                }
            }

            // Clear all the caught messages
            await this.Context.Channel.DeleteMessagesAsync(filtered);

            // Format the channel and time
            string channel =
                MentionUtils.MentionChannel(this.Context.Message.Channel.Id);

            // Format how many messages were filtered
            int numFiltered = filtered.Count;

            if ((user == null) || (user.Id == sender.Id))
            {
                numFiltered -= 1; // Don't count the command message
            }
            string messageCount =
                numFiltered + ((numFiltered == 1) ? " message" : " messages");

            await this.ReplyAsync(
                $"{sender.Mention} purged {messageCount} " +
                ((user == null) ? "" : $"by {user.Mention} ") +
                $"sent within {Util.PrintHuman(time)} in {channel}" +
                (string.IsNullOrEmpty(reason) ? "." : $", reason: {reason}"));
        }
예제 #8
0
            public async Task RemindInternal(ulong targetId, bool isPrivate, string timeStr, [Remainder] string message)
            {
                var m = timeIntervalRegex.Match(timeStr);

                if (m.Success)
                {
                    var timeValues = new Dictionary <string, int>();

                    foreach (var groupName in timeIntervalRegex.GetGroupNames())
                    {
                        if (groupName != "0")
                        {
                            timeValues[groupName] = !string.IsNullOrEmpty(m.Groups[groupName].Value) && int.TryParse(m.Groups[groupName].Value, out var value) ? value : 0;
                        }
                    }

                    var timespan = new TimeSpan(timeValues["days"], timeValues["hours"], timeValues["minutes"], timeValues["seconds"]);
                    var time     = DateTime.UtcNow + timespan;

                    var rem = new Reminder {
                        ChannelId = targetId,
                        IsPrivate = isPrivate,
                        When      = time,
                        Message   = message,
                        UserId    = Context.User.Id,
                        ServerId  = Context.Guild.Id
                    };

                    uow.Reminders.Add(rem);
                    await uow.SaveChangesAsync(false).ConfigureAwait(false);

                    var gTime = TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(Context.Guild.Id));
                    _ = Task.Run(() => Service.StartReminder(rem));
                    await Context.Channel.SendConfirmAsync($"⏰ {(GetText("remind", !isPrivate ? MentionUtils.MentionChannel(targetId) : Context.User.Username, timespan, gTime, message.SanitizeMentions()))}").ConfigureAwait(false);
                }
                else
                {
                    await ReplyErrorLocalized("remind_invalid_format").ConfigureAwait(false);
                }
            }
예제 #9
0
        public async Task StartRoleplayAsync
        (
            [NotNull]
            [RequireEntityOwnerOrPermission(typeof(StartStopRoleplay), PermissionTarget.Other)]
            Roleplay roleplay
        )
        {
            var startRoleplayResult = await _roleplays.StartRoleplayAsync(this.Context, roleplay);

            if (!startRoleplayResult.IsSuccess)
            {
                await _feedback.SendErrorAsync(this.Context, startRoleplayResult.ErrorReason);

                return;
            }

            var getDedicatedChannelResult = await _roleplays.GetDedicatedRoleplayChannelAsync
                                            (
                this.Context.Guild,
                roleplay
                                            );

            // Make the channel visible for all participants
            if (getDedicatedChannelResult.IsSuccess)
            {
                var dedicatedChannel = getDedicatedChannelResult.Entity;

                foreach (var participant in roleplay.ParticipatingUsers)
                {
                    var user = await this.Context.Guild.GetUserAsync((ulong)participant.User.DiscordID);

                    if (user is null)
                    {
                        continue;
                    }

                    await _roleplays.SetDedicatedChannelWritabilityForUserAsync
                    (
                        dedicatedChannel,
                        user,
                        true
                    );

                    await _roleplays.SetDedicatedChannelVisibilityForUserAsync
                    (
                        dedicatedChannel,
                        user,
                        true
                    );
                }

                if (roleplay.IsPublic)
                {
                    var everyoneRole = this.Context.Guild.EveryoneRole;
                    await _roleplays.SetDedicatedChannelVisibilityForRoleAsync
                    (
                        dedicatedChannel,
                        everyoneRole,
                        true
                    );
                }
            }

            var joinedUsers    = roleplay.JoinedUsers.Select(async p => await this.Context.Client.GetUserAsync((ulong)p.User.DiscordID));
            var joinedMentions = joinedUsers.Select(async u => (await u).Mention);

            // ReSharper disable once PossibleInvalidOperationException
            var channel = await this.Context.Guild.GetTextChannelAsync((ulong)roleplay.ActiveChannelID);

            var activationMessage = $"The roleplay \"{roleplay.Name}\" is now active in " +
                                    $"{MentionUtils.MentionChannel(channel.Id)}.";

            var participantList = (await Task.WhenAll(joinedMentions)).Humanize();
            await _feedback.SendConfirmationAsync
            (
                this.Context,
                activationMessage
            );

            await channel.SendMessageAsync($"Calling {participantList}!");
        }
        private async Task HandleMessageDelete(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
        {
            var guild = (channel as IGuildChannel)?.Guild;

            if (guild == null)
            {
                Log.LogInformation("Recieved message update event for non-guild message, ignoring");
                return;
            }

            if (await ShouldSkip(guild, channel))
            {
                return;
            }

            var embed = new EmbedBuilder();
            var descriptionContent = $"**Content**\n```Unknown, message not cached```";

            if (message.HasValue)
            {
                var cached = message.Value;

                //Don't log when messages from Modix are deleted
                if (message.Value.Author.Id == _discordClient.CurrentUser.Id)
                {
                    return;
                }

                descriptionContent = $"**Content**\n```{FormatMessage(cached.Content)}```";

                embed = embed
                        .WithUserAsAuthor(cached.Author, cached.Author.Id.ToString());

                if (cached.Attachments.Any())
                {
                    embed = embed.AddField
                            (
                        field => field
                        .WithName("Attachments")
                        .WithValue(string.Join(", ", cached.Attachments.Select(d => $"{d.Filename} ({d.Size}b)")))
                            );
                }
            }

            embed = embed
                    .WithDescription(descriptionContent)
                    .WithCurrentTimestamp();

            await SelfExecuteRequest <IMessageRepository>(async messages =>
            {
                using (var transaction = await messages.BeginMaintainTransactionAsync())
                {
                    await messages.DeleteAsync(message.Id);
                    transaction.Commit();
                }
            });

            await TryLog(
                guild,
                $":wastebasket:Message Deleted in {MentionUtils.MentionChannel(channel.Id)} `{message.Id}`",
                embed.Build());
        }
예제 #11
0
        public (string, EmbedBuilder) GetGameMessage(GameResult game, string title = null, params GameFlag[] flags)
        {
            bool usermentions = flags.Contains(GameFlag.usermentions);

            bool gamestate        = flags.Contains(GameFlag.gamestate);
            bool map              = flags.Contains(GameFlag.map);
            bool time             = flags.Contains(GameFlag.time);
            bool lobby            = flags.Contains(GameFlag.lobby);
            bool pickmode         = flags.Contains(GameFlag.pickmode);
            bool submitter        = flags.Contains(GameFlag.submitter);
            bool remainingPlayers = false;
            bool winningteam      = false;
            bool team1            = false;
            bool team2            = false;

            var message = usermentions ? string.Join(" ", game.Queue.Select(x => MentionUtils.MentionUser(x))) : "";

            var embed = new EmbedBuilder
            {
                Color = Color.Blue
            };

            embed.Title = title ?? $"Game #{game.GameId}";
            var desc = "";

            if (time)
            {
                desc += $"**Creation Time:** {game.CreationTime.ToString("dd MMM yyyy")} {game.CreationTime.ToShortTimeString()}\n";
            }

            if (pickmode)
            {
                desc += $"**Pick Mode:** {game.GamePickMode}\n";
            }

            if (lobby)
            {
                desc += $"**Lobby:** {MentionUtils.MentionChannel(game.LobbyId)}\n";
            }

            if (map && game.MapName != null)
            {
                desc += $"**Map:** {game.MapName}\n";
            }

            if (gamestate)
            {
                team1 = true;
                team2 = true;

                switch (game.GameState)
                {
                case GameResult.State.Canceled:
                    desc       += "**State:** Cancelled\n";
                    embed.Color = Color.DarkOrange;
                    break;

                case GameResult.State.Draw:
                    desc       += "**State:** Draw\n";
                    embed.Color = Color.Gold;
                    break;

                case GameResult.State.Picking:
                    remainingPlayers = true;
                    embed.Color      = Color.Magenta;
                    break;

                case GameResult.State.Decided:
                    winningteam = true;
                    embed.Color = Color.Green;
                    break;

                case GameResult.State.Undecided:
                    break;
                }
            }

            if (winningteam)
            {
                var teamInfo = game.GetWinningTeam();
                embed.AddField($"Winning Team, Team #{teamInfo.Item1}", teamInfo.Item2.GetTeamInfo());
                if (teamInfo.Item1 == 1)
                {
                    team1 = false;
                }
                else if (teamInfo.Item1 == 2)
                {
                    team2 = false;
                }
            }

            if (team1)
            {
                embed.AddField("Team 1", game.Team1.GetTeamInfo());
            }

            if (team2)
            {
                embed.AddField("Team 2", game.Team2.GetTeamInfo());
            }

            if (remainingPlayers)
            {
                var remaining = game.GetQueueRemainingPlayers();
                if (remaining.Any())
                {
                    embed.AddField("Remaining Players", string.Join(" ", game.GetQueueRemainingPlayers().Select(MentionUtils.MentionUser)));
                }
            }

            embed.Description = desc;



            return(message, embed);
        }
        public async Task FreeGameNotificationSetupAsync([Summary("Channel to announce in for the free game annonucement.")] IChannel channel, [Summary("Role to mention for the free game announcement.")] IRole role = null)
        {
            var clientId = Context.Client.CurrentUser.Id.ToString();
            var guildId  = Context.Guild.Id.ToString();

            var freeGameNotificationModel = await SQLiteService.SQLiteAsyncConnection.Table <FreeGameNotificationModel>().Where(a => a.ClientId == clientId && a.GuildId == guildId).FirstOrDefaultAsync();

            if (freeGameNotificationModel == null)
            {
                await SQLiteService.SQLiteAsyncConnection.InsertAsync(new FreeGameNotificationModel { ClientId = clientId, GuildId = guildId, RoleId = role?.Id.ToString() ?? "", ChannelId = channel.Id.ToString() });
            }
            else
            {
                freeGameNotificationModel.RoleId    = role?.Id.ToString() ?? "";
                freeGameNotificationModel.ChannelId = channel.Id.ToString();
                await SQLiteService.SQLiteAsyncConnection.UpdateAsync(freeGameNotificationModel);
            }

            if (role != null)
            {
                await ReplyAsync($":white_check_mark: Successfully setup free game notification in {MentionUtils.MentionChannel(channel.Id)} with {role.Mention}.");
            }
            else
            {
                await ReplyAsync($":white_check_mark: Successfully setup free game notification in {MentionUtils.MentionChannel(channel.Id)}.");
            }
        }
예제 #13
0
        public async Task Farewell(params string[] args)
        {
            string farewell = string.Empty;

            if (args.Length == 0)
            {
                await ReplyAsync($"Insufficient parameters provided for farewell command.");
            }
            else
            {
                bool   enabled       = false;
                string enabledString = args[0];
                switch (enabledString.ToLower().Trim())
                {
                case "on":
                case "true":
                    enabled = true;
                    break;

                case "off":
                case "false":
                    break;

                default:
                    await ReplyAsync("Unable to determine if farewell should be enabled or disabled.");

                    return;
                }

                IChannel channel = null;
                if (args.Length > 1)
                {
                    string channelName = args[1];
                    var    channels    = await this.Context.Guild.GetChannelsAsync();

                    foreach (IChannel guildChan in channels)
                    {
                        if (channelName == MentionUtils.MentionChannel(guildChan.Id))
                        {
                            channel = guildChan;
                            break;
                        }
                    }
                }


                if (args.Length > 2)
                {
                    farewell = args.Skip(2).ToSentence();
                }
                if (enabled && channel is null)
                {
                    await ReplyAsync("Channel was not provided and is required.");
                }
                else if (enabled && string.IsNullOrWhiteSpace(farewell))
                {
                    await ReplyAsync("Farewell was not provided and is required.");
                }
                else
                {
                    Context.GuildConfiguration.FarewellOnPart = enabled;
                    Context.GuildConfiguration.SetFarewellChannel(channel);
                    Context.GuildConfiguration.Farewell = farewell;
                    BotConfiguration.Save();
                }
            }
        }
예제 #14
0
        private async Task OnUserJoined(SocketGuildUser arg)
        {
            _logger.LogInformation("User joined server");

            if (!(_client.GetChannel(_options.CurrentValue.ModuleConfiguration.Welcome.WelcomeChannelId) is IMessageChannel channel))
            {
                return;
            }

            await channel.SendMessageAsync(
                $"Hi {MentionUtils.MentionUser(arg.Id)} welcome to this very nice server. Pleas read the rules in {MentionUtils.MentionChannel(_options.CurrentValue.ModuleConfiguration.Welcome.RulesChannelId)} and accept them. After that you will gain full acces to this server.");
        }
예제 #15
0
        private Task CmdGetAsync(SocketCommandContext context, Match match, CancellationToken cancellationToken = default)
        {
            EmbedBuilder embed = this.StartEmbed(context);

            embed.AddField("Commands", $"Use **{this.GetPrefix(context)}commands** to get list of commands that you can use here!", inline: false);

            if (this.IsMainRestrictionGroup(context))
            {
                embed.AddField("Additional features",
                               "If you try to use an another bot in a wrong channel, I'll direct you to the correct channel.\n" +
                               $"I'll automatically post new or just finished Elite Dangerous Community Goals in {MentionUtils.MentionChannel(_eliteOptions.AutoNewsChannelID)}.\n" +
                               $"I'll post a message in {GetLeaveChannel(context)} when a user leaves the guild.",
                               inline: false);
            }
            else
            {
                embed.AddField("Additional features",
                               $"If I have permissions to post in {GetLeaveChannel(context)}, I'll post a message whenever a user leaves the guild.\n" +
                               $"More additional features are provided in {GetAuthorText(context)}'s server.", inline: false);
            }
            embed.AddField("Support",
                           $"To submit bugs or suggestions, please open an issue on [GitHub](https://github.com/TehGM/EinherjiBot/issues). Alternatively, you can message {GetAuthorText(context)}.\n" +
                           "To support the developer, consider donating on [GitHub Sponsors](https://github.com/sponsors/TehGM), [Patreon](https://patreon.com/TehGMdev) or [Buy Me A Coffee](https://www.buymeacoffee.com/TehGM). **Thank you!**",
                           inline: false);

            return(context.ReplyAsync(null, false, embed.Build(), cancellationToken));
        }
예제 #16
0
 /// <inheritdoc />
 public override string GetDescriptiveUIText()
 {
     return($"Has reacted to {this.MessageID} in {MentionUtils.MentionChannel((ulong)this.ChannelID)} " +
            $"with {this.EmoteName}");
 }
예제 #17
0
        public async Task VerificationPasswordChannel(ITextChannel channel)
        {
            var gc = uow.GuildConfigs.For(Context.Guild.Id);

            if (channel.Id == gc.VerificationPasswordChannelId)
            {
                await ErrorLocalized("passwordchannel_new_identical", channel.Mention).ConfigureAwait(false);
            }
            else
            {
                var oldPasswordChannelId = gc.VerificationPasswordChannelId;

                gc.VerificationPasswordChannelId = channel.Id;

                uow.GuildConfigs.Update(gc);
                await uow.SaveChangesAsync(false).ConfigureAwait(false);
                await ConfirmLocalized("passwordchannel_new", oldPasswordChannelId.HasValue?MentionUtils.MentionChannel(oldPasswordChannelId.Value) : "null", channel.Mention).ConfigureAwait(false);
            }
        }
예제 #18
0
 public static string Mention(this IChannel self) => MentionUtils.MentionChannel(self.Id);
예제 #19
0
        private async Task ListWarningsAsync(string message, ICollection <Warning> warnings, IMessageChannel target)
        {
            var warningEmbeds = new List <EmbedBuilder> {
                new EmbedBuilder()
            };

            foreach (var w in warnings)
            {
                var warningStr =
                    $"**{(w.Amount == 0 ? "Initial Warning" : w.Amount == 1 ? "Warning" : "Strike")} {w.Id} " +
                    $"({w.IssueDate:MM/dd/yyyy}{(w.RemoveDate.HasValue ? $", removed on {w.RemoveDate.Value:MM/dd/yyyy}" : "")})**\n" +
                    $"{w.Reason}\n" +
                    (w.RemoveReason == null ? "" : $"Remove Reason: {w.RemoveReason}\n") +
                    $"[{GetUnmentionedUser(w.IssuerId)}](https://discordapp.com/channels/{DiscordSettings.GuildId}/{w.ChannelId}/{w.MessageId}) " +
                    $"in {MentionUtils.MentionChannel(w.ChannelId)} " +
                    (w.RemoveChannelId.HasValue && w.RemoveMessageId.HasValue && w.RemoverId.HasValue
                        ? $" | Removed by [{GetUnmentionedUser(w.RemoverId.Value)}](https://discordapp.com/channels/{DiscordSettings.GuildId}/{w.RemoveChannelId.Value}/{w.RemoveMessageId.Value}) in {MentionUtils.MentionChannel(w.ChannelId)}\n\n"
                        : "\n\n");

                if (warningEmbeds.Last().Description?.Length + warningStr.Length > 2048)
                {
                    warningEmbeds.Add(new EmbedBuilder());
                }

                warningEmbeds.Last().Description += warningStr;
            }

            await target.SendMessageAsync(message, embed : warnings.Count > 0?warningEmbeds[0].Build() : null);

            foreach (var embedBuilder in warningEmbeds.Skip(1))
            {
                await target.SendMessageAsync(embed : embedBuilder.Build());
            }
        }
예제 #20
0
        public async Task SetupLogChannel()
        {
            Options         guildOptions = GlobalVars.GuildOptions.Single(x => x.GuildID == Context.Guild.Id).Options;
            RestUserMessage msg;

            if (guildOptions.LogChannelID == 0)
            {
                msg = await Context.Channel.SendMessageAsync($"{Context.User.Mention}: Do you wish this channel to be used for logging?");
            }
            else
            {
                msg = await Context.Channel.SendMessageAsync($"{Context.User.Mention}: Do you wish to change the logging channel from {MentionUtils.MentionChannel(guildOptions.LogChannelID)} to {MentionUtils.MentionChannel(Context.Channel.Id)}?");
            }
            GlobalVars.AddLogChannelTracker(msg, Context.Message.Author.Id);
            await msg.AddReactionsAsync(new Emoji[] { new Emoji("✅"), new Emoji("🚫") });
        }
        public async Task ListAsync()
        {
            var channels = await DesignatedChannelService.GetDesignatedChannelsAsync(Context.Guild.Id);

            // https://mod.gg/config/channels
            var url = new UriBuilder(Config.WebsiteBaseUrl)
            {
                Path = "/config/channels"
            }.RemoveDefaultPort().ToString();

            var builder = new EmbedBuilder()
            {
                Title     = "Assigned Channel Designations",
                Url       = url,
                Color     = Color.Gold,
                Timestamp = DateTimeOffset.UtcNow
            };

            foreach (var type in Enum.GetValues(typeof(DesignatedChannelType)).Cast <DesignatedChannelType>())
            {
                var designatedChannels = channels
                                         .Where(x => x.Type == type)
                                         .ToArray();

                builder.AddField(new EmbedFieldBuilder()
                {
                    Name  = type.Humanize(),
                    Value = (designatedChannels.Length == 0)
                        ? Format.Italics("No channels assigned")
                        : string.Join(Environment.NewLine, designatedChannels.Select(x => MentionUtils.MentionChannel(x.Channel.Id))),
                    IsInline = false
                });
            }

            await ReplyAsync(embed : builder.Build());
        }
예제 #22
0
    public async Task MessageDeletedAsync(Cacheable <IMessage, ulong> messageId, Cacheable <IMessageChannel, ulong> socketCached)
    {
        var socket = await socketCached.GetOrDownloadAsync();

        if (socket is IGuildChannel socketGuild && socketGuild.GuildId == ACEGIKMO_SERVER && socket.Id != ACEGIKMO_DELETED_MESSAGES)
        {
            var modchannel = await socketGuild.Guild.GetTextChannelAsync(ACEGIKMO_DELETED_MESSAGES);

            if (_log.TryGetMessage(messageId.Id, out var message))
            {
                var after = _log.TryGetPreviousMessage(messageId.Id, socket.Id, out var previous)
                    ? $" after <https://discordapp.com/channels/{socketGuild.GuildId}/{previous.ChannelId}/{previous.MessageId}>"
                    : "";
                var toSend = $"Message by {MentionUtils.MentionUser(message.AuthorId)} deleted in {MentionUtils.MentionChannel(message.ChannelId)}{after}:\n{message.Message}";
                Console.WriteLine(toSend);
                await modchannel.SendMessageAsync(toSend);
            }
            else
            {
                await modchannel.SendMessageAsync($"Message deleted, but not found in DB: {messageId.Id}");
            }
        }
    }
예제 #23
0
        private async Task AddParticipationToEmbedAsync(
            ulong userId,
            StringBuilder builder,
            GuildUserParticipationStatistics userRank,
            IReadOnlyList <MessageCountByDate> messagesByDate,
            IReadOnlyList <MessageCountPerChannel> messageCountsByChannel,
            IReadOnlyCollection <EmojiUsageStatistics> emojiCounts)
        {
            var lastWeek = _utcNow - TimeSpan.FromDays(7);

            var weekTotal  = 0;
            var monthTotal = 0;

            foreach (var kvp in messagesByDate.OrderByDescending(x => x.Date))
            {
                if (kvp.Date >= lastWeek)
                {
                    weekTotal += kvp.MessageCount;
                }

                monthTotal += kvp.MessageCount;
            }

            builder.AppendLine();
            builder.AppendLine("**\u276F Guild Participation**");

            if (userRank?.Rank > 0)
            {
                builder.AppendFormat("Rank: {0} {1}\n", userRank.Rank.Ordinalize(), GetParticipationEmoji(userRank));
            }

            var weekParticipation = "Last 7 days: " + weekTotal + " messages";

            if (weekTotal > 0 && monthTotal > 0)
            {
                var percentage = (int)((decimal)weekTotal / monthTotal * 100);
                weekParticipation += string.Format(" ({0}%)", percentage);
            }

            builder.AppendLine(weekParticipation);
            builder.AppendLine("Last 30 days: " + monthTotal + " messages");

            if (monthTotal > 0)
            {
                builder.AppendFormat(
                    "Avg. per day: {0} messages (top {1} percentile)\n",
                    decimal.Round(userRank.AveragePerDay, 3),
                    userRank.Percentile.Ordinalize());

                try
                {
                    foreach (var channelMessageCount in messageCountsByChannel.OrderByDescending(x => x.MessageCount))
                    {
                        var channel = await Context.Guild.GetChannelAsync(channelMessageCount.ChannelId);

                        if (channel.IsPublic())
                        {
                            builder.AppendLine($"Most active channel: {MentionUtils.MentionChannel(channel.Id)} ({channelMessageCount.MessageCount} messages)");
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.LogDebug(ex, "Unable to get the most active channel for {UserId}.", userId);
                }
            }

            if (emojiCounts.Any())
            {
                var favoriteEmoji = emojiCounts.First();

                var emojiFormatted = ((SocketSelfUser)Context.Client.CurrentUser).CanAccessEmoji(favoriteEmoji.Emoji)
                    ? Format.Url(favoriteEmoji.Emoji.ToString(), favoriteEmoji.Emoji.Url)
                    : $"{Format.Url("❔", favoriteEmoji.Emoji.Url)} (`{favoriteEmoji.Emoji.Name}`)";

                builder.AppendLine($"Favorite emoji: {emojiFormatted} ({"time".ToQuantity(favoriteEmoji.Uses)})");
            }
        }
예제 #24
0
 /// <inheritdoc />
 public override string GetDescriptiveUIText()
 {
     return($"{this.RequiredCount} messages in {MentionUtils.MentionChannel((ulong)this.SourceID)}");
 }
        public async Task <RuntimeResult> ShowOrCreateDedicatedRoleplayChannel
        (
            [RequireEntityOwnerOrPermission(typeof(StartStopRoleplay), PermissionTarget.Other)]
            Roleplay roleplay
        )
        {
            var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync
                                            (
                this.Context.Guild,
                roleplay
                                            );

            if (getDedicatedChannelResult.IsSuccess)
            {
                var existingDedicatedChannel = getDedicatedChannelResult.Entity;
                var message = $"\"{roleplay.Name}\" has a dedicated channel at " +
                              $"{MentionUtils.MentionChannel(existingDedicatedChannel.Id)}";

                return(RuntimeCommandResult.FromSuccess(message));
            }

            await _feedback.SendConfirmationAsync(this.Context, "Setting up dedicated channel...");

            // The roleplay either doesn't have a channel, or the one it has has been deleted or is otherwise invalid.
            var result = await _dedicatedChannels.CreateDedicatedChannelAsync
                         (
                this.Context.Guild,
                roleplay
                         );

            if (!result.IsSuccess)
            {
                return(result.ToRuntimeResult());
            }

            var dedicatedChannel = result.Entity;

            if (!roleplay.IsActive || roleplay.ActiveChannelID == (long)dedicatedChannel.Id)
            {
                return(RuntimeCommandResult.FromSuccess
                       (
                           $"All done! Your roleplay now has a dedicated channel at " +
                           $"{MentionUtils.MentionChannel(dedicatedChannel.Id)}."
                       ));
            }

            var stopResult = await StopRoleplayAsync(roleplay);

            if (!stopResult.IsSuccess)
            {
                return(stopResult);
            }

            var startResult = await StartRoleplayAsync(roleplay);

            if (!startResult.IsSuccess)
            {
                return(startResult);
            }

            return(RuntimeCommandResult.FromSuccess
                   (
                       $"All done! Your roleplay now has a dedicated channel at " +
                       $"{MentionUtils.MentionChannel(dedicatedChannel.Id)}."
                   ));
        }
예제 #26
0
 public UserInfoEmbedBuilderHelper WithChannel(ulong channelId,
                                               int numberOfMessagesInChannel)
 {
     _content.AppendLine($"Most active channel: {MentionUtils.MentionChannel(channelId)} ({numberOfMessagesInChannel} messages)");
     return(this);
 }
예제 #27
0
        public async Task ConfigureServerAsync()
        {
            ulong configChannelId;
            ulong reminderChannelId;

            // config channel
            await ReplyAndDeleteAsync($"Tag the channel you want **configuration** messages sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1));

            var response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30));

            if (response != null)
            {
                if (response.MentionedChannels.FirstOrDefault() != null)
                {
                    configChannelId = MentionUtils.ParseChannel(response.Content);
                }
                else
                {
                    await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus.");

                    return;
                }
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");

                return;
            }


            // reminder channel
            await ReplyAndDeleteAsync($"Tag the channel you want **reminders & the schedule** sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1));

            response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30));

            if (response != null)
            {
                if (response.MentionedChannels.FirstOrDefault() != null)
                {
                    reminderChannelId = MentionUtils.ParseChannel(response.Content);
                }
                else
                {
                    await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus.");

                    return;
                }
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");

                return;
            }

            // build our new server object
            var newServer = new DbDiscordServer()
            {
                ConfigChannelId   = configChannelId.ToString(),
                ReminderChannelId = reminderChannelId.ToString(),
                ServerId          = Context.Guild.Id.ToString(),
                ServerName        = Context.Guild.Name,
                RemindersEnabled  = true
            };

            // add this server's data to the database
            await DatabaseServers.AddServerInfo(newServer);

            // initialize this server
            RaidEventsService.SetServerDiscordObjects(newServer);

            // update the ServerList with the new server
            DbDiscordServers.ServerList.Add(newServer);

            // set up google api authentication
            await AuthAsync();
        }
        public async Task SuggestAsync(string type, [Remainder] string suggestion)
        {
            var messages = await Context.Channel.GetMessagesAsync(1).FlattenAsync();


            if (_suggestionService.Process(out var channel, type.ToLower()))
            {
                var builder = new EmbedBuilder()
                              .WithInformationColor()
                              .AddField($"New suggestion made by {Context.User.Username} in #{Context.Channel.Name}", suggestion)
                              .WithCurrentTimestamp();

                var embed = builder.Build();

                await channel.SendMessageAsync(embed : embed);

                await(Context.Channel as SocketTextChannel).DeleteMessagesAsync(messages);

                var successEmbedBuilder = new EmbedBuilder()
                                          .WithSucessColor()
                                          .WithBoldDescription($"I have added you suggestion succesfully and posted it in {MentionUtils.MentionChannel(channel.Id)} to be voted on.")
                                          .WithCurrentTimestamp();

                var successEmbed = successEmbedBuilder.Build();

                var msg = await(Context.Channel as SocketTextChannel).SendMessageAsync(embed: successEmbed);

                await Task.Delay(5000);

                await msg.DeleteAsync();
            }

            return;
        }
예제 #29
0
 public async Task MsgXpRestrictions()
 {
     using (var uow = _db.UnitOfWork)
     {
         if (!uow.MessageXpBlacklist.GetAll().Any())
         {
             await ErrorLocalized("msgxpr_none").ConfigureAwait(false);
         }
         else
         {
             await Context.Channel.SendConfirmAsync(GetText("msgxpr_title"),
                                                    uow.MessageXpBlacklist
                                                    .GetAll()
                                                    .OrderByDescending(m => m.ChannelId)
                                                    .Aggregate("", (s, m) => $"{s}{MentionUtils.MentionChannel(m.ChannelId)}, ",
                                                               s => s.Substring(0, s.Length - 2)))
             .ConfigureAwait(false);
         }
     }
 }
예제 #30
0
        private Dictionary <string, Action <CommandRequest> > GenerateCommands()
        {
            return(new Dictionary <string, Action <CommandRequest> >()
            {
                {
                    CommandConstants.AddServer, async(commandRequest) =>
                    {
                        if (commandRequest.NeedHelp)
                        {
                            var eb = new EmbedBuilder
                            {
                                Title = $"{CommandConstants.AddServer}",

                                ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png",

                                Color = Color.Teal
                            };

                            var fieldBuilder = new EmbedFieldBuilder
                            {
                                Name = "Adds a server to the tracking list",

                                Value = "field"
                            };

                            eb.AddField("Usage", fieldBuilder.Build());

                            eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands");

                            eb.Description = $"{Config.Prefix}{CommandConstants.AddServer} 123.456.789.10:12345 rconPassword";

                            await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build());
                        }
                        else
                        {
                            await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin);

                            await commandRequest.Message.DeleteAsync();

                            if (commandRequest.Message.Channel.Name != ChannelNames.Admin)
                            {
                                var adminChannel = await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin) as IChannel;

                                await commandRequest.Message.Channel.SendMessageAsync($"That command must be used in {MentionUtils.MentionChannel(adminChannel.Id)}");
                            }
                            else
                            {
                                var guild = GuildManagers.FirstOrDefault(x => x.Guild.Id == commandRequest.Guild.Id);

                                var server = guild.Servers.FirstOrDefault(x => x.IpAddress == commandRequest.Arguments[1]);

                                if (server != null)
                                {
                                    await commandRequest.Message.Channel.SendMessageAsync($"That server (ID: {server.ID}) is already being followed. Use {Config.Prefix}{CommandConstants.ServerList} to find it");
                                }
                                else
                                {
                                    bool error = false;

                                    var ipPort = commandRequest.Arguments[1].Split(':');

                                    if (ipPort.Length != 2)
                                    {
                                        error = true;
                                    }

                                    if (commandRequest.Arguments.Length != 3)
                                    {
                                        error = true;
                                    }

                                    if (!error)
                                    {
                                        var ip = ipPort[0];
                                        var port = Convert.ToUInt16(ipPort[1]);

                                        server = new CsServer(ip, port, commandRequest.Arguments[2], Config, guild, guild.ServerId);

                                        await server.InitializeRconAsync();

                                        if (server.Authed)
                                        {
                                            var eb = new EmbedBuilder
                                            {
                                                Title = $"Server Added ✅",

                                                ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png",

                                                Color = Color.Teal
                                            };

                                            var idField = new EmbedFieldBuilder
                                            {
                                                Name = $"{server.ID}",
                                                Value = "field"
                                            };

                                            var ipField = new EmbedFieldBuilder
                                            {
                                                Name = $"{ip}:{port}",

                                                Value = "field"
                                            };

                                            eb.AddField("ID", idField.Build());

                                            eb.AddField("IP Address", ipField.Build());

                                            eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands");

                                            await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build());

                                            server.ChatMessageEventArgs += CsServerChatMessageAsync;

                                            server.MatchStartEventArgs += CsServerMatchLiveAsync;

                                            server.TacMessageEventArgs += CsServerTacPauseAsync;

                                            server.TechMessageEventArgs += CsServerTechPauseAsync;

                                            server.MatchSwapSidesEventArgs += CsServerSwapSidesAsync;

                                            server.UnpauseMessageEventArgs += CsServerUnpauseAsync;

                                            server.ScoreUpdateEventsArgs += CsServerScoreUpdateAsycAsync;

                                            server.OnGenericUpdateEventArgs += CsServerGenericBroadcastUpdateAsync;

                                            server.MatchEndEventArgs += CsServerMatchEndAsync;

                                            guild.Servers.Add(server);

                                            guild.ServerId++;
                                        }
                                        else
                                        {
                                            var eb = new EmbedBuilder
                                            {
                                                Title = $"❌ FAILED TO AUTHENTICATE ❌",

                                                ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png",

                                                Color = Color.Teal
                                            };

                                            var reasonField = new EmbedFieldBuilder
                                            {
                                                Name = $"Failed to authenticate, make sure rcon password is correct",
                                                Value = "field"
                                            };

                                            eb.AddField("Reason", reasonField.Build());

                                            eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands");

                                            await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build());
                                        }
                                    }
                                    else
                                    {
                                        await commandRequest.Message.Channel.SendMessageAsync($"Command syntax is incorrect. Use {Config.Prefix}{CommandConstants.AddServer} 123.45.678:12345 rconPassword");
                                    }
                                }
                            }
                        }
                    }
                },
                {
                    CommandConstants.ServerList, async(commandRequest) =>
                    {
                        if (commandRequest.NeedHelp)
                        {
                            var eb = new EmbedBuilder
                            {
                                Title = $"{CommandConstants.AddServer}",

                                ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png",

                                Color = Color.Teal
                            };

                            var fieldBuilder = new EmbedFieldBuilder
                            {
                                Name = "Lists all servers being tracked on this discord server",

                                Value = "field"
                            };

                            eb.AddField("Usage", fieldBuilder.Build());

                            eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands");

                            eb.Description = $"{Config.Prefix}{CommandConstants.ServerList}";

                            await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build());
                        }
                        else
                        {
                            await ValidateBotCategoryAsync(commandRequest);
                            await ValidateAdminChannel(commandRequest);

                            if (commandRequest.Message.Channel.Name != ChannelNames.Admin)
                            {
                                var adminChannel = await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin) as IChannel;

                                await commandRequest.Message.Channel.SendMessageAsync($"That command must be used in {MentionUtils.MentionChannel(adminChannel.Id)}");
                            }
                            else
                            {
                                var serverList = string.Empty;

                                var guild = GuildManagers.FirstOrDefault(x => x.Guild.Id == commandRequest.Guild.Id);

                                foreach (var server in guild.Servers)
                                {
                                    serverList = $"{serverList} [{server.ID}] {server.IpAddress}\n";
                                }

                                serverList = $"```\n{serverList}\n```";

                                await commandRequest.Message.Channel.SendMessageAsync(serverList);
                            }
                        }
                    }
                },
                {
                    CommandConstants.Help, async(commandRequest) =>
                    {
                        var commandList = string.Empty;

                        foreach (var key in Commands.Keys.Where(x => x != CommandConstants.Help))
                        {
                            commandList = $"{commandList} {key}\n";
                        }

                        commandList = $"```\n{commandList}\n {Config.Prefix}CommandName Help for more information```";

                        await commandRequest.Message.Channel.SendMessageAsync(commandList);
                    }
                }
            });
        }