Esempio n. 1
0
        private async Task Client_MessageDeleted(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
        {
            SocketTextChannel textChannel = channel as SocketTextChannel;
            RestAuditLogEntry logEntry    = await GetAuditLogEntry(textChannel.Guild);

            if (logEntry.Action != ActionType.MessageDeleted)
            {
                return;
            }
            MessageDeleteAuditLogData data = (MessageDeleteAuditLogData)logEntry.Data;
            IUser user = await channel.GetUserAsync(data.AuthorId);

            string targetUsername = "******" + user + "** _(" + data.AuthorId + ")_";
            string adminUsername  = "******" + logEntry.User + "**";

            string msg = adminUsername + " deleted _" + data.MessageCount + "_ messages by " + targetUsername +
                         " in **#" + channel.Name + "** channel";

            foreach (SocketTextChannel chan in Global.SECURITY_CHANNELS)
            {
                if (chan.Guild.Id == textChannel.Guild.Id)
                {
                    if (!CheckPosted(logEntry, chan))
                    {
                        await SendSecurityLog(msg, new Color(255, 190, 0), chan, logEntry.Id.ToString(), logEntry.User.GetAvatarUrl());
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        public async Task <string> GetParticipantsMessageBody(ISocketMessageChannel channel, EventsWithCount @event, List <EventSignup> signups, bool showJoinPrompt = true)
        {
            var users = await Task.WhenAll(signups.Select(async sup => (await channel.GetUserAsync(Convert.ToUInt64(sup.UserId)) as SocketGuildUser)));

            var usersInEvent = string.Join(Environment.NewLine, users.Select(u => u.GetDisplayName()));
            var message      = $"**{@event.Name}**{Environment.NewLine}";

            if (@event.SpaceLimited)
            {
                message += $"There's {users.Length} out of {@event.Capacity}";
            }
            else
            {
                message += $"There's {users.Length}";
            }

            message += $" racers signed up for {@event.Name}.{Environment.NewLine}{ usersInEvent}{Environment.NewLine}{Environment.NewLine}";

            if (showJoinPrompt)
            {
                if ([email protected])
                {
                    message += $"React to this message to join the event!";
                }
                else if (@event.SpaceLimited && @event.Full)
                {
                    message += "This event is currently full. Keep an eye out in case somebody unsigns.";
                }
            }

            return(message);
        }
Esempio n. 3
0
        private async Task OnReactionAdded(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel ch, SocketReaction reaction)
        {
            var                 dlTasks = new List <Task>();
            IUserMessage        msg     = null;
            Task <IUserMessage> msgTask = null;

            if (cache.HasValue)
            {
                msg = cache.Value;
            }
            else
            {
                msgTask = cache.DownloadAsync();
                dlTasks.Add(msgTask);
            }

            IGuildUser   user     = null;
            Task <IUser> userTask = null;

            if (reaction.User.IsSpecified)
            {
                user = reaction.User.Value as IGuildUser;
            }
            else
            {
                userTask = ch.GetUserAsync(reaction.UserId);
                dlTasks.Add(userTask);
            }
            await Task.WhenAll(dlTasks);

            if (msg == null)
            {
                msg = await msgTask;
            }
            if (user == null)
            {
                user = await userTask as IGuildUser;
            }

            // Don't process bot reaction
            if (user.IsBot || user.IsWebhook)
            {
                return;
            }

            try{
                _logger.LogDebug($"{user.Username}#{user.Discriminator}> reaction {reaction.Emote.Name}");
                var code = _automuteService.GetVCLinkedGameCode(user.VoiceChannel);
                if (code is null)
                {
                    return;
                }
                await _automuteService.OnReactionAdded(msg, user, reaction, code);
            }catch (Exception e) {
                _logger.LogDebug($"{e.GetType()} -- {e.Message}");
                using (_logger.BeginScope("")){ _logger.LogDebug(e.StackTrace); }
            }
        }
Esempio n. 4
0
        private static async Task OnReactionRemoved(ulong MessageID, ISocketMessageChannel NewMsg, SocketReaction react)
        {
            if (MessageID == ServerConfigData.ServerRoleSetUpMsgID && react.UserId != Program.ServerConfigData.PointersAnonUserID["Quantum Bot"])
            {
                foreach (KeyValuePair <string, ChannelRoles> EmoteData in Program.ChannelRolesData)
                {
                    if (react.Emote.Equals(EmoteData.Value.ChannelReactEmote))
                    {
                        await(react.User.Value as SocketGuildUser).RemoveRoleAsync((NewMsg as SocketGuildChannel).Guild.GetRole(EmoteData.Value.RoleID));

                        //NO LOGIC CHECK FOR WHO GETS WHAT ROLES
                        await(NewMsg as SocketGuildChannel).Guild.GetTextChannel(ServerConfigData.PointersAnonChatID["Bot History"]).SendMessageAsync($"User <@{react.UserId}> removed role {EmoteData.Key}");
                        return;
                    }
                }

                return;
            }


            foreach (BulletinEvent bulletinEvent in Program.BulletinBoardData.BulletinEvents)
            {
                if (MessageID == bulletinEvent.MsgID && react.UserId != Program.ServerConfigData.PointersAnonUserID["Quantum Bot"] && react.Emote.Equals(BulletinBoardData.BulletinAttendingEmote))
                {
                    if (bulletinEvent.AttendingUsers.Contains(react.UserId) == true)
                    {
                        bulletinEvent.AttendingUsers.Remove(react.UserId);
                        await(NewMsg as SocketGuildChannel).Guild.GetTextChannel(ServerConfigData.PointersAnonChatID["Bot History"]).SendMessageAsync($"User <@{react.UserId}> is no longer going to the Event \"{bulletinEvent.Title}\"");
                    }

                    var builder = new EmbedBuilder()
                                  .WithTitle(bulletinEvent.Title)
                                  .WithUrl($"{bulletinEvent.EventURL}")
                                  .WithColor(new Color(0, 0, 255))
                                  .WithDescription($"{bulletinEvent.Description}")
                                  .WithThumbnailUrl($"{bulletinEvent.IconURL}")
                                  .AddField($"Time", bulletinEvent.EventDate.ToString("MMMM d yyyy \ndddd h:mm tt"), true)
                                  .AddField($"Location", $"{bulletinEvent.Location}", true)
                                  .AddField($"Cost", $"{bulletinEvent.Cost}", true)
                                  .AddField($"Capacity", $"{bulletinEvent.Capacity}", true)
                                  .AddField($"Attending", $"{bulletinEvent.AttendingUsers.Count}", true)
                                  .WithFooter($"By {(await NewMsg.GetUserAsync(bulletinEvent.author) as SocketGuildUser).Nickname}", $"{bulletinEvent.authorIconURL}")
                                  .WithTimestamp(bulletinEvent.embedCreated);

                    var embed = builder.Build();

                    var msg = await NewMsg.GetMessageAsync(MessageID) as IUserMessage;

                    await msg.ModifyAsync(x => x.Embed = embed);

                    //add atending emote
                    SaveBulletinBoardDataToFile();
                    await msg.AddReactionAsync(BulletinBoardData.BulletinAttendingEmote);

                    return;
                }
            }
        }
Esempio n. 5
0
        private async Task OnMessageReactionAdd(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            try
            {
                if (!message.HasValue)
                {
                    return;
                }
                if (message.HasValue && message.Value.Source != MessageSource.Bot)
                {
                    return;
                }
                if (reaction.User.Value.IsBot)
                {
                    return;
                }

                var chnl         = channel as SocketGuildChannel;
                var guildEmojies = chnl.Guild.Emotes;

                if (!guildEmojies.Any(x => x.Name == reaction.Emote.Name))
                {
                    return;
                }

                var emote             = reaction.Emote as Emote;
                var emojiFromExchange = await _refExchangeRepository.GetRefExchangeFromEmoji(emote.Id);

                if (emojiFromExchange == null)
                {
                    return;
                }

                var links = emojiFromExchange.Reflinks;

                if (!links.Any())
                {
                    return;
                }

                var random = new Random();
                var index  = random.Next(links.Count);

                var luckyLink = links.ElementAt(index);

                var user = await channel.GetUserAsync(reaction.UserId);

                await channel.SendMessageAsync($"{user.Mention}: <{luckyLink.Link}>");
            }
            catch (Exception e)
            {
                Log.Error(e, "Failed Excetuing command async");
            }
        }
Esempio n. 6
0
        public async Task Handle(Cacheable <IUserMessage, ulong> msg, ISocketMessageChannel chan, SocketReaction r)
        {
            if (r.UserId == Program._client.CurrentUser.Id)
            {
                return;
            }
            if (r.MessageId == BotConfig.GetCachedConfig().InternalMessageId)
            {
                if (r.Emote.Name == "🔄")
                {
                    var actualMessage = await chan.GetMessageAsync(r.MessageId);

                    await actualMessage.RemoveReactionAsync(r.Emote, r.UserId);

                    if (!debounce && !ServerStateManager.Instance().IsWorking) // ignore attempts to spam the button
                    {
                        debounce = true;
                        var status = await ServerStateManager.Instance().GetState();

                        if (status.InstanceState.Code == 80)
                        {
                            Console.WriteLine("User ID" + r.UserId + " initated a server start.");
                            ThreadPool.QueueUserWorkItem(async delegate
                            {
                                try
                                {
                                    await ServerStateManager.Instance().StartServer();
                                }
                                catch (AmazonEC2Exception e)
                                {
                                    Console.WriteLine("AWS threw an error.");
                                    Console.Write(e.Message);
                                    ServerStateManager.Instance().IsWorking = false;
                                    await Embeds.EditMessage(Embeds.ServerStopped("The server could not be started previously due to an error. Please wait a bit and try again, or ask an admin if this persists. This mainly happens after starting a server when it's just been stopped."));
                                }
                            });
                        }
                        else
                        {
                            Console.WriteLine("Rejecting refresh as server is not stopped.");
                            if (Program._client.GetUser(r.UserId) != null)
                            {
                                var usr = await chan.GetUserAsync(r.UserId);

                                await usr.SendMessageAsync(embed : Embeds.Error("The server must be stopped for the refresh button to work."));
                            }
                        }
                        debounce = false;
                    }
                }
            }
        }
Esempio n. 7
0
        public async Task <Embed> GetParticipantsEmbed(ISocketMessageChannel channel, EventsWithCount @event, List <EventSignup> signups, bool showJoinPrompt = true)
        {
            var users = new List <SocketGuildUser>();

            foreach (var signup in signups)
            {
                var user = await channel.GetUserAsync(Convert.ToUInt64(signup.UserId)) as SocketGuildUser;

                if (user == null)
                {
                    //handle user that left the guild
                    await _eventSignups.DeleteAsync(signup);

                    continue;
                }
                users.Add(user);
            }

            var usersInEvent = string.Join('\n', users.Select(u => u.GetDisplayName()));
            var message      = "";

            if (@event.SpaceLimited)
            {
                message += $"There's {users.Count} out of {@event.Capacity}";
            }
            else
            {
                message += $"There's {users.Count}";
            }

            message += $" racers signed up for {@event.Name}.\n\n{ usersInEvent}\n";

            var builder = new EmbedBuilder()
                          .WithTitle(@event.Name)
                          .WithDescription(message);

            if (showJoinPrompt)
            {
                if ([email protected])
                {
                    builder.WithFooter(footer => footer.WithText("React to this message to join this event!"));
                }
                else if (@event.SpaceLimited && @event.Full)
                {
                    builder.WithFooter(footer => footer.WithText("This event is currently full. Keep an eye out in case somebody unsigns"));
                }
            }
            return(builder.Build());
        }
Esempio n. 8
0
        /// <summary>
        /// This method returns a SocketGuildUser object of the user that placed a reaction.
        /// </summary>
        /// <param name="channel">The channel of the mesasge being reacted to</param>
        /// <param name="reaction">The reaction placed on the message</param>
        /// <returns>The user as a SocketGuildUser, or null if the reaction was placed by a bot.</returns>
        public static async Task <SocketGuildUser> GetUserAsync(ISocketMessageChannel channel, SocketReaction reaction)
        {
            SocketGuildUser user;

            if (reaction.User.IsSpecified)
            {
                user = (SocketGuildUser)reaction.User;
            }
            else
            {
                user = await channel.GetUserAsync(reaction.UserId) as SocketGuildUser;
            }

            if (user.IsBot)
            {
                return(null);
            }

            return(user);
        }
Esempio n. 9
0
        private async Task ReactionAddedEvent(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            IUserMessage    msg  = message.DownloadAsync().Result;
            SocketGuildUser user = await channel.GetUserAsync(reaction.UserId) as SocketGuildUser;

            SocketGuild    guild   = user.Guild;
            DungeonManager manager = new DungeonManager();

            GuildConfig config = new GuildConfig(guild.Id.ToString());

            config.CheckForFile();
            config = config.Load() as GuildConfig;

            if (config.DungeonChannelID != channel.Id || config.DungeonMessageID != message.Id ||
                user.IsBot)
            {
                return;
            }

            // Check if valid emote
            for (int i = 0; i < DungeonManager.EMOTES.Length; i++)
            {
                if (DungeonManager.EMOTES[i].Equals(reaction.Emote))
                {
                    break;
                }
                else if (i == DungeonManager.EMOTES.Length - 1)
                {
                    return;
                }
            }

            Embed newEmbed = manager.RefreshMonsterCard(msg.Embeds.First(), guild, user);
            await msg.ModifyAsync(x => x.Embed = newEmbed);

            await msg.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
        }
Esempio n. 10
0
        /// <inheritdoc/>
        protected override async Task <OperationResult> ReactionAddedAsync
        (
            Cacheable <IUserMessage, ulong> message,
            ISocketMessageChannel channel,
            SocketReaction reaction
        )
        {
            var reactingUser = await channel.GetUserAsync(reaction.UserId);

            if (reactingUser.IsBot || reactingUser.IsWebhook)
            {
                return(OperationResult.FromSuccess());
            }

            if (!(reactingUser is IGuildUser guildUser))
            {
                return(OperationResult.FromSuccess());
            }

            using var eventScope = this.Services.CreateScope();
            var userStatistics = eventScope.ServiceProvider.GetRequiredService <UserStatisticsService>();

            return(await UpdateLastActivityTimestampForUserAsync(userStatistics, guildUser));
        }
Esempio n. 11
0
        private async Task UpdateMessage(bool added, Cacheable <IUserMessage, ulong> userMessage, ISocketMessageChannel messageChannel, SocketReaction reaction)
        {
#if DEBUG
            if (messageChannel.Id == Channels.DEV)
#else
            if (messageChannel.Id == Channels.CSGaming)
#endif
            {
                var message = await userMessage.GetOrDownloadAsync();

                if (message?.Content.Contains("Vilka ska vara med och spela lunch-cs idag?") ?? false)
                {
                    var user = await messageChannel.GetUserAsync(reaction.UserId);

                    if (!reactionTimes.ContainsKey(message.Id))
                    {
                        reactionTimes.Add(message.Id, new Dictionary <ulong, DateTime>());
                    }

                    if (added)
                    {
                        if (!reactionTimes[message.Id].ContainsKey(user.Id))
                        {
                            reactionTimes[message.Id].Add(user.Id, DateTime.Now);
                        }
                    }
                    else
                    {
                        if (reactionTimes[message.Id].ContainsKey(user.Id))
                        {
                            reactionTimes[message.Id].Remove(user.Id);
                        }
                    }

                    var newContent = voting_template;

                    int i = 1;
                    foreach (var r in reactionTimes[message.Id].OrderBy(x => x.Value))
                    {
                        user = await messageChannel.GetUserAsync(r.Key);

                        if (i == 6)
                        {
                            newContent += "Och på avbytarbänken har vi:\n";
                        }

                        IGuildUser guildUser = (IGuildUser)user;
                        var        nickname  = string.IsNullOrEmpty(guildUser?.Nickname) || guildUser?.Nickname == user.Username ? string.Empty : $"({guildUser.Nickname})";

                        newContent += $"{i.ToString()}. {user.Username} {nickname}: {r.Value.ToString("HH:mm:ss")}\n";

                        i++;
                    }

                    await message.ModifyAsync((x) =>
                    {
                        x.Content = newContent;
                    });
                }
            }
        }
Esempio n. 12
0
        private static async Task OnReactionAdded(ulong MessageID, ISocketMessageChannel NewMsg, SocketReaction react)
        {
            //Assign Roles based off of reaction to the emote
            if (MessageID == ServerConfigData.ServerRoleSetUpMsgID && react.UserId != Program.ServerConfigData.PointersAnonUserID["Quantum Bot"])
            {
                foreach (KeyValuePair <string, ChannelRoles> EmoteData in Program.ChannelRolesData)
                {
                    if (react.Emote.Equals(EmoteData.Value.ChannelReactEmote))
                    {
                        //Checks if certified student
                        var AllRoles = (react.User.Value as SocketGuildUser).Roles;
                        var Guilds   = (NewMsg as SocketGuildChannel).Guild;
                        if (AllRoles.Contains(Guilds.GetRole(ServerConfigData.PointersAnonRoleID["Student"])) || AllRoles.Contains(Guilds.GetRole(ServerConfigData.PointersAnonRoleID["Guest"])) || AllRoles.Contains(Guilds.GetRole(ServerConfigData.PointersAnonRoleID["Teacher"])))
                        {
                            //If you get a null ref exception. It's because the role ID is bad
                            await(react.User.Value as SocketGuildUser).AddRoleAsync(Guilds.GetRole(EmoteData.Value.RoleID));

                            await(NewMsg as SocketGuildChannel).Guild.GetTextChannel(ServerConfigData.PointersAnonChatID["Bot History"]).SendMessageAsync($"User <@{react.UserId}> gained role {EmoteData.Key}");
                            return;
                        }
                        else
                        {
                            await(await NewMsg.GetMessageAsync(MessageID) as IUserMessage).RemoveReactionAsync(react.Emote, react.User.Value);
                            await(NewMsg as SocketGuildChannel).Guild.GetTextChannel(ServerConfigData.PointersAnonChatID["Bot History"]).SendMessageAsync($"User <@{react.UserId}> tried to gained role {EmoteData.Key}, but does not have the proper perms");
                        }
                    }
                }

                return;
            }


            foreach (BulletinEvent bulletinEvent in Program.BulletinBoardData.BulletinEvents)
            {
                if (MessageID == bulletinEvent.MsgID && react.UserId != Program.ServerConfigData.PointersAnonUserID["Quantum Bot"] && react.Emote.Equals(BulletinBoardData.BulletinAttendingEmote))
                {
                    if (bulletinEvent.AttendingUsers.Contains(react.UserId) == false)
                    {
                        bulletinEvent.AttendingUsers.Add(react.UserId);
                        await(NewMsg as SocketGuildChannel).Guild.GetTextChannel(ServerConfigData.PointersAnonChatID["Bot History"]).SendMessageAsync($"User <@{react.UserId}> is going to the Event \"{bulletinEvent.Title}\"");
                    }

                    var builder = new EmbedBuilder()
                                  .WithTitle(bulletinEvent.Title)
                                  .WithUrl($"{bulletinEvent.EventURL}")
                                  .WithColor(new Color(0, 0, 255))
                                  .WithDescription($"{bulletinEvent.Description}")
                                  .WithThumbnailUrl($"{bulletinEvent.IconURL}")
                                  .AddField($"Time", bulletinEvent.EventDate.ToString("MMMM d yyyy \ndddd h:mm tt"), true)
                                  .AddField($"Location", $"{bulletinEvent.Location}", true)
                                  .AddField($"Cost", $"{bulletinEvent.Cost}", true)
                                  .AddField($"Capacity", $"{bulletinEvent.Capacity}", true)
                                  .AddField($"Attending", $"{bulletinEvent.AttendingUsers.Count}", true)
                                  .WithFooter($"By {(await NewMsg.GetUserAsync(bulletinEvent.author) as SocketGuildUser).Nickname}", $"{bulletinEvent.authorIconURL}")
                                  .WithTimestamp(bulletinEvent.embedCreated);

                    var embed = builder.Build();

                    var msg = await NewMsg.GetMessageAsync(MessageID) as IUserMessage;

                    await msg.ModifyAsync(x => x.Embed = embed);

                    //add atending emote
                    SaveBulletinBoardDataToFile();
                    await msg.AddReactionAsync(BulletinBoardData.BulletinAttendingEmote);

                    return;
                }
            }
        }
Esempio n. 13
0
        private async Task MessageDeleted(Cacheable <IMessage, ulong> cacheObject, ISocketMessageChannel channel)
        {
            await _channelsSemaphore.WaitAsync();

            try
            {
                if (_monitoredChannels.Contains(channel.Id) && cacheObject.HasValue)
                {
                    var message        = cacheObject.Value;
                    var mentionedUsers = message.MentionedUserIds;
                    var mentionedRoles = message.MentionedRoleIds;
                    if (!mentionedRoles.Any() && !mentionedUsers.Any())
                    {
                        return;
                    }
                    var author        = message.Author;
                    var stringBuilder = new StringBuilder();
                    stringBuilder.Append(
                        $"I can feel a ghost in here... {_emoteList.ElementAt(_rand.Next(0, _emoteList.Count()))}" +
                        $"\n{author.Mention} just tried to ghostping ");

                    if (mentionedUsers.Any())
                    {
                        stringBuilder.Append("these people:");
                        foreach (var userId in mentionedUsers)
                        {
                            stringBuilder.Append(" ");
                            var user = await channel.GetUserAsync(userId);

                            stringBuilder.Append(user.Username);
                        }
                    }

                    if (mentionedRoles.Any())
                    {
                        if (mentionedUsers.Any())
                        {
                            stringBuilder.Append("\n");
                            stringBuilder.Append("and also these roles:");
                        }
                        else
                        {
                            stringBuilder.Append("these roles:");
                        }

                        foreach (var roleId in mentionedRoles)
                        {
                            stringBuilder.Append(" ");
                            var role = ((IGuildChannel)message.Channel).Guild.GetRole(roleId);
                            stringBuilder.Append(role.Name);
                        }
                    }

                    await channel.SendMessageAsync(stringBuilder.ToString());
                }
            }
            finally
            {
                _channelsSemaphore.Release();
            }
        }
        private async Task ReactionRemovedAsync(Cacheable <IUserMessage, ulong> messageCacheable, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.UserId == client.CurrentUser.Id)
            {
                return;
            }

            var messageId       = messageCacheable.Id;
            var eventForMessage = DbContext.Events.AsQueryable().Where(e => e.EventMessageId == messageId).FirstOrDefault();

            if (eventForMessage != null)
            {
                //Must do this, as the message in the Cacheable is not available 90% of time.
                var message = await messageCacheable.GetOrDownloadAsync();

                var role           = RoleExtensions.EmojiToRole(reaction.Emote.Name);
                var existingSignup = eventForMessage.Signups.FirstOrDefault(e => (e.Role == role || e.ReserveRole == role) && e.UserId == reaction.UserId);
                if (existingSignup != null)
                {
                    //If someone is a role-specific-reserve, we only remove their signup if they hit the role emoji, not the reserve emoji.
                    if (role == Role.Reserve && existingSignup.ReserveRole != Role.None)
                    {
                        return;
                    }

                    bool wasFull     = eventForMessage.IsFull();
                    bool roleWasFull = eventForMessage.IsRoleFull(role);

                    eventForMessage.RemoveSignup(existingSignup);
                    DbContext.SaveChanges();
                    if (channel is IGuildChannel guildChannel)
                    {
                        eventForMessage.UpdateSignupsOnMessageAsync(message, guildChannel.Guild);
                    }

                    var user = await channel.GetUserAsync(reaction.UserId);

                    if (user != null)
                    {
                        var returnTask = user.SendMessageAsync($"You are no longer joining {eventForMessage.EventName}");

                        Signup nextReserve = null;

                        if (wasFull && !eventForMessage.IsFull())
                        {
                            var leaderMsg = $"Your event {eventForMessage.EventName} is no longer full, as {user.Username} is no longer joining";
                            nextReserve = eventForMessage.GetNextReserve();
                            if (nextReserve != null)
                            {
                                var nextReserveUser = await message.Channel.GetUserAsync(nextReserve.UserId);

                                leaderMsg += $"\nAs {nextReserveUser.Username} is the first reserve, they have been notified";
                            }

                            var leaderUser = await channel.GetUserAsync(eventForMessage.LeaderUserID);

                            await returnTask.ContinueWith(t => leaderUser.SendMessageAsync(leaderMsg));
                        }
                        else if (roleWasFull && !eventForMessage.IsRoleFull(role))
                        {
                            nextReserve = eventForMessage.GetNextReserve(role);
                        }

                        if (nextReserve != null)
                        {
                            var reserveUser = await channel.GetUserAsync(nextReserve.UserId);

                            await returnTask.ContinueWith(t => reserveUser.SendMessageAsync($"A spot has opened up in {eventForMessage.EventName} and you are next on the reserves!"));
                        }

                        await returnTask;
                    }
                }
            }

            return;
        }
        private async Task ReactionAddedAsync(Cacheable <IUserMessage, ulong> messageCacheable, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.UserId == client.CurrentUser.Id)
            {
                return;
            }

            //Must do this, as the message in the Cacheable is not available 90% of time.
            var message = await messageCacheable.GetOrDownloadAsync();

            var messageId       = messageCacheable.Id;
            var eventForMessage = DbContext.Events.AsQueryable().Where(e => e.EventMessageId == messageId).FirstOrDefault();

            if (eventForMessage != null)
            {
                //Remove people adding emojies we don't recognise
                var role = RoleExtensions.EmojiToRole(reaction.Emote.Name);
                if (role == Role.None)
                {
                    var msgTask = message.RemoveReactionAsync(reaction.Emote, reaction.UserId);
                    return;
                }

                //This is to handle people that were moved into reserve due to an event being modified
                if (role == Role.Reserve && eventForMessage.Signups.Any(e => e.Role == Role.Reserve && e.UserId == reaction.UserId))
                {
                    return;
                }
                bool wasFull      = eventForMessage.IsFull();
                var  didAddSignup = eventForMessage.TryAddSignup(role, reaction.UserId);

                var user = await channel.GetUserAsync(reaction.UserId);

                if (didAddSignup)
                {
                    DbContext.SaveChanges();

                    if (channel is IGuildChannel guildChannel)
                    {
                        eventForMessage.UpdateSignupsOnMessageAsync(message, guildChannel.Guild);
                    }
                    var msgTask = user.SendMessageAsync($"You successfully signed up to {eventForMessage.EventName} as {role.GetEmoji()}. Have fun!");

                    if (eventForMessage.IsFull() && !wasFull)
                    {
                        var leaderUser = await channel.GetUserAsync(eventForMessage.LeaderUserID);

                        await msgTask.ContinueWith(t => leaderUser.SendMessageAsync($"Your event {eventForMessage.EventName} is now full!"));
                    }

                    await msgTask;
                }
                else
                {
                    var signup = new Signup(Role.Reserve, role, false, DateTime.Now, reaction.UserId);
                    eventForMessage.TryAddSignup(signup);
                    DbContext.SaveChanges();
                    if (channel is IGuildChannel guildChannel)
                    {
                        eventForMessage.UpdateSignupsOnMessageAsync(message, guildChannel.Guild);
                    }

                    await user.SendMessageAsync($"Sorry, you were placed in reserve for {eventForMessage.EventName} because we don't need any more {role.GetEmoji()}'s");
                }
            }

            return;
        }
Esempio n. 16
0
        private async Task OnReactionadd(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel ch, SocketReaction reac)
        {
            Account acc = Global.AccountList.Find(a => a.DiscordID == reac.UserId);

            if (!(acc == null))
            {
                if (Global.MsgGrade.ContainsKey(reac.MessageId))
                {
                    var   key  = reac.MessageId;
                    Grade grde = Global.MsgGrade[key];

                    if (grde.obs == null)
                    {
                        if (!reac.Emote.Name.Equals("❌"))
                        {
                            grde.atv = Global.AtvsEmojis[reac.Emote.Name];
                            Global.MsgGrade.Remove(key);
                            EmbedBuilder embed = new EmbedBuilder();
                            embed.WithColor(40, 200, 150);
                            embed.WithTitle("Algo a declarar?");
                            embed.WithDescription("Adicione Observações em sua Grade!\n Me envie uma mensagem com as observações que deseja adicionar a grade, se não quiser nenhuma envie **0**\n Lembre-se de mencionar armas, Poder e outros atributos que considera importante para o sucesso da missão!");
                            RestUserMessage x = await ch.SendMessageAsync("", false, embed.Build());

                            Global.MsgGrade.Add(x.Id, grde);
                            acc.EstadodeAcao = Flag.escrevendo;
                            acc.lastmsg      = x.Id;
                            grde.Msg         = x.Id;
                        }
                        else
                        {
                            grde.stat = Status.Cancelada;
                            EmbedBuilder embed = new EmbedBuilder();
                            embed.WithColor(250, 0, 0);
                            embed.WithTitle("Grade Cancelada");

                            RestUserMessage x = await ch.SendMessageAsync("", false, embed.Build());
                        }
                    }
                    else if (grde.MaxMembers != 0)

                    {
                        Grade g = Global.MsgGrade[reac.MessageId];
                        if (reac.Emote.Name.Equals("❌"))
                        {
                            if (g.Principais.Find(a => a.DiscordID == acc.DiscordID) != null)
                            {
                                if (acc.DiscordID == g.Organizador.DiscordID)
                                {
                                    g.Organizador.EstadodeAcao = Flag.deletando_grade;
                                    acc.EstadodeAcao           = Flag.deletando_grade;
                                    g.stat = Status.Cancelada;
                                    EmbedBuilder embed = new EmbedBuilder();
                                    embed.WithColor(250, 0, 0);
                                    embed.WithTitle("Está desistindo??");
                                    embed.WithDescription($"\n Por que essa grade foi cancelada?: {g.atv} - {g.time}");

                                    var u = await ch.GetUserAsync(reac.UserId);

                                    await UserExtensions.SendMessageAsync(u, "", false, embed.Build());
                                }
                                else
                                {
                                    g.Principais.RemoveAll(A => A.DiscordID == acc.DiscordID);
                                    RestUserMessage x = await reac.Channel.SendMessageAsync("\n Pressione AQUI para poder Reagir \n", false, Global.EmbedGrade(g).Build());

                                    Global.MsgGrade.Remove(g.Organizador.lastmsg);
                                    Global.MsgGrade.Add(x.Id, g);
                                    g.Organizador.lastmsg = x.Id;
                                    g.Msg = x.Id;
                                }
                            }
                            if (g.Reserva.Find(a => a.DiscordID == acc.DiscordID) != null)
                            {
                                g.Reserva.RemoveAll(A => A.DiscordID == acc.DiscordID);
                                RestUserMessage x = await reac.Channel.SendMessageAsync("\n Pressione AQUI para poder Reagir \n", false, Global.EmbedGrade(g).Build());

                                Global.MsgGrade.Remove(g.Organizador.lastmsg);
                                Global.MsgGrade.Add(x.Id, g);
                                g.Organizador.lastmsg = x.Id;
                                g.Msg = x.Id;
                            }
                        }
                        else if (reac.Emote.Name.Equals("👋"))
                        {
                            if (g.Reserva.Find(a => a.DiscordID == acc.DiscordID) == null && g.Principais.Find(a => a.DiscordID == acc.DiscordID) == null)
                            {
                                g.Reserva.Add(acc);
                                RestUserMessage x = await reac.Channel.SendMessageAsync("\n Pressione AQUI para poder Reagir \n", false, Global.EmbedGrade(g).Build());

                                Global.MsgGrade.Remove(g.Organizador.lastmsg);
                                Global.MsgGrade.Add(x.Id, g);
                                g.Organizador.lastmsg = x.Id;
                                g.Msg = x.Id;
                            }
                        }
                        else if (g.Principais.Count <= g.MaxMembers)
                        {
                            if (g.Principais.Find(a => a.DiscordID == acc.DiscordID) == null && g.Reserva.Find(a => a.DiscordID == acc.DiscordID) == null)
                            {
                                g.Principais.Add(acc);
                                RestUserMessage x = await reac.Channel.SendMessageAsync("\n Pressione AQUI para poder Reagir \n", false, Global.EmbedGrade(g).Build());

                                Global.MsgGrade.Remove(g.Organizador.lastmsg);
                                Global.MsgGrade.Add(x.Id, g);
                                g.Organizador.lastmsg = x.Id;
                                g.Msg = x.Id;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
0
 public static async Task <SocketGuildUser> GetClientGuildUserAsync(ISocketMessageChannel channel)
 => (SocketGuildUser)await channel.GetUserAsync(Client.CurrentUser.Id);
Esempio n. 18
0
        private async Task CheckInitThread(Cacheable<IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            var usr = await arg2.GetUserAsync(arg3.UserId);
            if (usr.IsBot)
                return;

            if (Setups.ContainsKey(arg2.Id))
            {
                var msg = await arg2.GetMessageAsync(Setups[arg2.Id].Key);

                //checkmark
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    if (client.GetGuild(Global.SwissGuildId).Users.Any(x => x.Id == usr.Id))
                    {
                        if (BlockedUsers.Any(x => x == usr.Id))
                        {
                            await arg2.SendMessageAsync("", false, new EmbedBuilder()
                            {
                                Title = "You are blocked!",
                                Description = "Looks like your blocked from creating support tickets :/",
                                Color = Color.Red
                            }.Build());
                            Setups.Remove(arg2.Id);
                            await msg.DeleteAsync();
                            return;
                        }
                        else
                        {
                            await msg.DeleteAsync();
                            var tmpmsg = await arg2.SendMessageAsync("**Creating support ticket with the staff team...**");
                            await CreateNewTicket(arg2, usr, Setups[arg2.Id].Value);
                            await tmpmsg.ModifyAsync(x => x.Embed = new EmbedBuilder()
                            {
                                Title = "Congrats! You are now talking with staff!",
                                Description = "Please note staff **Can** take moderation action for anything you say in a ticket. The same rules apply as the server.\n_This ticket may also be archived and used for training purposes._",
                                Color = Color.Green
                            }.Build());
                        }
                    }
                    else
                    {
                        await usr.SendMessageAsync("", false, new EmbedBuilder()
                        {
                            Title = "Sorry... :(",
                            Description = "The staff team does not accept tickets from users who are not in the server.",
                            Color = Color.Red
                        }.Build());
                    }

                }
                else if (arg3.Emote.Equals(new Emoji("❌"))) // xmark
                {
                    Setups.Remove(arg2.Id);
                    await msg.DeleteAsync();
                }
            }
            else if (closingState.Keys.Any(x => x.Key == arg2.Id))
            {
                var o = closingState.First(x => x.Key.Key == arg2.Id);
                var msg = await arg2.GetMessageAsync(o.Key.Value);

                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    o.Value.Stop();
                    o.Value.Dispose();
                    closingState.Remove(o.Key);
                    await msg.DeleteAsync();
                }
            }
            else if (WelcomeMessages.Contains(arg3.MessageId))
            {
                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    await msg.DeleteAsync();
                }
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    var ticket = CurrentTickets.Find(x => x.TicketChannel == arg2.Id);
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    var dmchan = await client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();
                    var gusr = usr as SocketGuildUser;
                    await msg.DeleteAsync();
                    string tmsg = $"**[Staff] {(gusr.Nickname == null ? usr.ToString() : gusr.Nickname)}** - Hello! Swiss001 Support! How May I help you?";
                    await arg2.SendMessageAsync(tmsg);
                    await dmchan.SendMessageAsync(tmsg);
                }
            }
        }
Esempio n. 19
0
        private async Task MessageReceived(SocketMessage context)
        {
            ///static bool countd = false;
            SocketUser socketUser;

            socketUser = context.Author;
            MessageSource         messageType   = context.Source;
            ISocketMessageChannel socketChannel = context.Channel;
            IUser  iuser;
            string user          = socketUser.Username;
            ulong  iD            = socketUser.Id;
            UInt16 discriminator = socketUser.DiscriminatorValue;
            string newmsg        = "";
            string msg           = context.Content;

            if (msg.StartsWith("u!team "))
            {
                msg = msg.Replace("u!team ", " ");
                int n = WordCounting.CountWords1(msg, "@") + 1;

                string[] msg1 = Pings.Split(msg);

                new Random().Shuffle(msg1);

                int j = msg1.Length;//3
                for (int i = 0; i < ((msg1.Length) / 2); i++)
                {
                    j--;
                    if (j == i)
                    {
                        await context.Channel.SendMessageAsync((msg1[i].ToString() + " is alone").ToString());

                        break;
                    }
                    else if (i - j == 1)
                    {
                        newmsg = newmsg + (msg1[i].ToString() + " is alone").ToString();
                        break;
                    }
                    newmsg = newmsg + ("Team " + (i + 1).ToString() + ": " + msg1[i].ToString() + " and " + msg1[j].ToString() + "\n").ToString();
                }



                await context.Channel.SendMessageAsync(newmsg);
            }
            else if (msg.StartsWith("u!countdown "))
            {
                msg = msg.Replace("u!countdown", " ");
                //countd=true;
                for (int i = int.Parse(msg); i > 0; i--)
                {
                    //if(!countd)break;
                    await Task.Delay(2000);

                    await context.Channel.SendMessageAsync(i.ToString());
                }
            }
            else if (msg.StartsWith("u!coin"))
            {
                Random random       = new Random();
                int    randomNumber = random.Next(0, 2);
                msg = msg.Replace("u!coin", " ");
                if (int.TryParse(msg, out int number))
                {
                    if (int.Parse(msg) > 333)
                    {
                        newmsg = newmsg + "I cant do more than 333 coin flips";
                        await context.Channel.SendMessageAsync(newmsg.ToString());
                    }
                    else
                    {
                        for (int i = 0; i < number - 1; i++)
                        {
                            randomNumber = random.Next(0, 2);
                            if (randomNumber == 1)
                            {
                                msg = "Heads";
                            }
                            else
                            {
                                msg = "Tails";
                            }
                            newmsg = newmsg + msg + "\n";
                        }
                        randomNumber = random.Next(0, 2);
                        if (randomNumber == 1)
                        {
                            msg = "Heads";
                        }
                        else
                        {
                            msg = "Tails";
                        }
                        newmsg = newmsg + msg + "\n";

                        await context.Channel.SendMessageAsync(newmsg.ToString());
                    }
                }
                else
                {
                    if (randomNumber == 1)
                    {
                        msg = "Heads";
                    }
                    else
                    {
                        msg = "Tails";
                    }
                    newmsg = newmsg + msg + "\n";
                    await context.Channel.SendMessageAsync(msg.ToString());
                }
            }
            else if (msg.StartsWith("u!dice "))
            {
                string msg1 = "";
                int    min, max;
                Random random       = new Random();
                int    randomNumber = random.Next(0, 2);
                msg  = msg.Replace("u!dice", "");
                msg1 = Regex.Match(msg, @"-?\d+").Value;
                max  = int.Parse(msg1);
                var regex = new Regex(Regex.Escape(max.ToString()));
                msg = regex.Replace(msg, "", 1);
                Console.WriteLine("msg je " + msg);
                if (int.TryParse(msg, out int number2))
                {
                    min = number2;
                }
                else
                {
                    min = 1;
                }
                if (min == max)
                {
                    Console.WriteLine("Min i Max su isti");
                }
                else if (min > max)
                {
                    int klog = min; min = max; max = klog;
                }
                Console.WriteLine("Min je " + min + " ,a max je " + max);
                randomNumber = random.Next(min, max + 1);
                await context.Channel.SendMessageAsync("<@" + iD + "> " + " rolled " + randomNumber.ToString());
            }
            else if (msg.StartsWith("u!rps"))
            {
                msg = msg.Replace("u!rps ", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                int[]    threw        = new int[names.Length];


                for (int i = 0; i < names.Length; i++)
                {
                    randomNumber = random.Next(0, 3);
                    switch (randomNumber)
                    {
                    case 0:
                        threw[i] = randomNumber;
                        newmsg   = newmsg + names[i] + ": :v: \n";
                        break;

                    case 1:
                        threw[i] = randomNumber;
                        newmsg   = newmsg + names[i] + ": :fist: \n";
                        break;

                    case 2:
                        threw[i] = randomNumber;
                        newmsg   = newmsg + names[i] + ": :hand_splayed: \n";
                        break;
                    }
                    Console.WriteLine((i + "" + threw[i]).ToString());
                }

                int win    = 0;
                int winnie = 0;
                Console.WriteLine(("\nlenght je" + names.Length).ToString());
                for (int i = 0; i < names.Length; i++)
                {
                    win = 0;
                    for (int j = 0; j < names.Length; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }
                        if (threw[i] == 1 && threw[j] == 0)
                        {
                            win++;
                            if (win == names.Length - 1)
                            {
                                winnie = i + 1;
                            }
                        }
                        else if (threw[i] == 2 && threw[j] == 1)
                        {
                            win++;
                            if (win == names.Length - 1)
                            {
                                winnie = i + 1;
                            }
                        }
                        else if (threw[i] == 0 && threw[j] == 2)
                        {
                            win++;
                            if (win == names.Length - 1)
                            {
                                winnie = i + 1;
                            }
                        }
                    }
                }
                Console.WriteLine(("\ntrenutni winnie je " + winnie).ToString());
                if (winnie != 0)
                {
                    newmsg = newmsg + names[winnie - 1] + " WINS";
                }
                else if (winnie == 0 && win != 0)
                {
                    newmsg = newmsg + "NO ONE WINS";
                }
                else
                {
                    newmsg = newmsg + "NO RESULT";
                }
                await context.Channel.SendMessageAsync(newmsg);
            }
            else if (msg.StartsWith("u!slap "))
            {
                string title = "";
                msg = msg.Replace("u!slap", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
                {
                    title = user + " slaps themself";
                }
                else
                {
                    names[0] = names[0].Remove(0, 2);
                    names[0] = names[0].Replace(">", "");
                    ulong.TryParse(names[0], out ulong result);
                    iuser = await socketChannel.GetUserAsync(result);

                    title = user + " slaps " + iuser.Username + " ";
                }
                string[] gif = new string[0];
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494144313404555274/giphy.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494147027064717322/3b3c291b732c757fc2a9d0f18d34402e37349b73_hq.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494147468787843092/original.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494147323169865728/tumblr_mflza5vE4o1r72ht7o2_400.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494147192068767744/never_ending_bitch_slap_by_yindragon-d4kiubr.gif");
                randomNumber = random.Next(0, gif.Length);
                Console.WriteLine(gif.Length.ToString());
                var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
                var embed   = builder.Build();
                await context.Channel.SendMessageAsync("", embed : embed);
            }
            else if (msg.StartsWith("u!cuddle "))
            {
                string title = "";
                msg = msg.Replace("u!cuddle", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
                {
                    title = user + " cuddles themself";
                }
                else
                {
                    names[0] = names[0].Remove(0, 2);
                    names[0] = names[0].Replace(">", "");
                    ulong.TryParse(names[0], out ulong result);
                    iuser = await socketChannel.GetUserAsync(result);

                    title = user + " cuddles " + iuser.Username + " ";
                }
                string[] gif = new string[0];
                gif          = Pings.add(gif, "https://media1.tenor.com/images/dc2bfb487be830983df6f8cc61e89368/tenor.gif?itemid=13797838");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/54e97e0cdeefea2ee6fb2e76d141f448/tenor.gif?itemid=11378437");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/88f1121f72f5fbfe4bc90c51cf82937f/tenor.gif?itemid=5047796");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/adeb030aaa5a2a3d16abdc58be4d1448/tenor.gif?itemid=11733535");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/4a211d5c5d076ad8795d8a82f9f01c29/tenor.gif?itemid=13221038");
                randomNumber = random.Next(0, gif.Length);
                Console.WriteLine(gif.Length.ToString());
                var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
                var embed   = builder.Build();
                await context.Channel.SendMessageAsync("", embed : embed);
            }
            else if (msg.StartsWith("u!hug "))
            {
                string title = "";
                msg = msg.Replace("u!hug", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
                {
                    title = user + " hugs themself";
                }
                else
                {
                    names[0] = names[0].Remove(0, 2);
                    names[0] = names[0].Replace(">", "");
                    ulong.TryParse(names[0], out ulong result);
                    iuser = await socketChannel.GetUserAsync(result);

                    title = user + " hugs " + iuser.Username + " ";
                }
                string[] gif = new string[0];
                gif          = Pings.add(gif, "https://media.tenor.com/images/d5c635dcb613a9732cfd997b6a048f80/tenor.gif");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/42922e87b3ec288b11f59ba7f3cc6393/tenor.gif?itemid=5634630");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/1069921ddcf38ff722125c8f65401c28/tenor.gif?itemid=11074788");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/460c80d4423b0ba75ed9592b05599592/tenor.gif?itemid=5044460");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/44b4b9d5e6b4d806b6bcde2fd28a75ff/tenor.gif?itemid=9383138");
                gif          = Pings.add(gif, "https://images-ext-2.discordapp.net/external/dwTWixM8K-ZizvgespNWYLLV3LtHY1J3pen3pq4IGGQ/https/i.giphy.com/rSNAVVANV5XhK.gif");
                gif          = Pings.add(gif, "https://media.tenor.com/images/a756a73934fb6252bb9acf174d019c73/tenor.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/613686019077832704/613687991399088138/Friends-1.gif");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/5845f40e535e00e753c7931dd77e4896/tenor.gif?itemid=9920978");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/7ece0d6e9306763eeea5e0c5284a3528/tenor.gif?itemid=14106855");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/7db5f172665f5a64c1a5ebe0fd4cfec8/tenor.gif?itemid=9200935");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/cd321aa5d055a7e02b52eea806b9797c/tenor.gif?itemid=12861205");
                randomNumber = random.Next(0, gif.Length);
                Console.WriteLine(gif.Length.ToString());
                var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
                var embed   = builder.Build();
                await context.Channel.SendMessageAsync("", embed : embed);
            }
            else if (msg.StartsWith("u!pat "))
            {
                string title = "";
                msg = msg.Replace("u!pat", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
                {
                    title = user + " pats themself";
                }
                else
                {
                    names[0] = names[0].Remove(0, 2);
                    names[0] = names[0].Replace(">", "");
                    ulong.TryParse(names[0], out ulong result);
                    iuser = await socketChannel.GetUserAsync(result);

                    title = user + " pats " + iuser.Username + " ";
                }
                string[] gif = new string[0];
                gif          = Pings.add(gif, "https://media1.tenor.com/images/f5176d4c5cbb776e85af5dcc5eea59be/tenor.gif?itemid=5081286");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/f330c520a8dfa461130a799faca13c7e/tenor.gif?itemid=13911345");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/54722063c802bac30d928db3bf3cc3b4/tenor.gif?itemid=8841561");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/282cc80907f0fe82d9ae1f55f1a87c03/tenor.gif?itemid=12018857");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/1e92c03121c0bd6688d17eef8d275ea7/tenor.gif?itemid=9920853");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/7938cdb8aa798486e2e2f1d997ea7797/tenor.gif?itemid=14816799");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/5466adf348239fba04c838639525c28a/tenor.gif?itemid=13284057");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/183ff4514cbe90609e3f286adaa3d0b4/tenor.gif?itemid=5518321");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/573c5aa94d1ab4ba9d32f369d35e1c8d/tenor.gif?itemid=14848813");
                gif          = Pings.add(gif, "https://media1.tenor.com/images/8c1f6874db27c8227755a08b2b07740b/tenor.gif?itemid=10789367");
                randomNumber = random.Next(0, gif.Length);
                Console.WriteLine(gif.Length.ToString());
                var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
                var embed   = builder.Build();
                await context.Channel.SendMessageAsync("", embed : embed);
            }
            else if (msg.StartsWith("u!kick "))
            {
                string title = "";
                msg = msg.Replace("u!kick", "");
                Random   random       = new Random();
                int      randomNumber = random.Next(0, 3);
                string[] names        = Pings.Split(msg);
                if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
                {
                    title = user + " kicks themself";
                }
                else
                {
                    names[0] = names[0].Remove(0, 2);
                    names[0] = names[0].Replace(">", "");
                    ulong.TryParse(names[0], out ulong result);
                    iuser = await socketChannel.GetUserAsync(result);

                    title = user + " kicks " + iuser.Username + " ";
                }
                string[] gif = new string[0];
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494562631588511744/kick5.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494562673619369994/kick1.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494562720549568512/kick2.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494577333576138763/kick3.gif");
                gif          = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494562816133431296/kick4.gif");
                randomNumber = random.Next(0, gif.Length);
                Console.WriteLine(gif.Length.ToString());
                var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
                var embed   = builder.Build();
                await context.Channel.SendMessageAsync("", embed : embed);
            }/*
              * else if (msg.StartsWith("u!gaykiss "))
              * {
              * string title = "";
              * msg = msg.Replace("u!gaykiss", "");
              * Random random = new Random();
              * int randomNumber = random.Next(0, 3);
              * string[] names = Pings.Split(msg);
              * if (names.Length == 0 || names[0] == ("<@" + iD + ">").ToString())
              *     title = user + " kisses themself";
              * else
              * {
              *     names[0] = names[0].Remove(0, 2);
              *     names[0] = names[0].Replace(">", "");
              *     ulong.TryParse(names[0], out ulong result);
              *     iuser = await socketChannel.GetUserAsync(result);
              *     title = user + " gaykisses " + iuser.Username + " ";
              * }
              * string[] gif = new string[0];
              * gif = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494576499051986964/gk1.gif");
              * gif = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494576517007933440/gk4.gif");
              * gif = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494576517670633482/gk3.gif");
              * gif = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494576520635875328/gk2.gif");
              * gif = Pings.add(gif, "https://cdn.discordapp.com/attachments/316675507628539905/494576524226330634/tumblr_inline_n67apaUGX81rgg4k4.gif");
              * randomNumber = random.Next(0, gif.Length);
              * Console.WriteLine(gif.Length.ToString());
              * var builder = new EmbedBuilder().WithTitle(title).WithImageUrl(gif[randomNumber]);
              * var embed = builder.Build();
              * await context.Channel.SendMessageAsync(    "",    embed: embed);
              * }*/
            else if (msg.StartsWith("u!help"))
            {
                newmsg = "```u!countdown <number> - counts down from a number \n\nu!rps < player 1 > < player 2 >...... [player n] - plays a rock, paper, scissors game with all the players\n\nu!coin[number] - flips a coin x times\n u!team < person 1 >< person 2 > ..........[person n] - makes teams of 2 with all the people mentioned\n\nu!dice < number 1 >[number 2] - randomly chooses a number from 1 to number1 or a number in between number1 and number2 \n\nu!slap <person1> - slaps\n\nu!gaykiss <person1> - gaykiss a person\n\nu!kick <person1> - kick a guy\n\n\n<something> -are necessary inputs \n[something] -are optional inputs```";
                await context.Channel.SendMessageAsync(newmsg);
            }
        }