Пример #1
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;
            var channel = message.Channel;

            if (!AkyBot.HasPermission(channel as SocketGuildChannel, GuildPermission.EmbedLinks))
            {
                await ChatMessage.SendError(message, "I don't have Embed Links Permission!");

                return;
            }

            var user = ChatMessage.FindUser(0, true);

            if (user == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            var avatarURL = user.DisplayAvatarURL();
            var embed     = new EmbedBuilder()
                            .WithTitle($"{user.Tag()}'s Avatar")
                            .WithImageUrl(avatarURL)
                            .WithColor(AkyBot.EmbedColor);
            await ChatMessage.Send(message, null, embed.Build());
        }
Пример #2
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;
            var args    = ChatMessage.Args;
            var author  = message.Author;
            var channel = message.Channel as SocketGuildChannel;
            var member  = author.GetMember(channel.Guild);

            if (!member.GuildPermissions.Has(GuildPermission.KickMembers))
            {
                await ChatMessage.SendError(message, "you do not have Kick Members Permission.");

                return;
            }
            if (!AkyBot.HasPermission(channel, GuildPermission.KickMembers, false))
            {
                await ChatMessage.SendError(message, "I do not have Kick Memebers Permission!");

                return;
            }
            if (args.Length == 0)
            {
                await ChatMessage.SendError(message, "you have to specify a user!");

                return;
            }
            var userToKick = ChatMessage.FindUser(args[0]);

            if (userToKick == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            if (userToKick == author)
            {
                await ChatMessage.SendError(message, "you can't kick yourself.");

                return;
            }
            if (userToKick == AkyBot.Client.CurrentUser)
            {
                await ChatMessage.SendError(message, "why do you wanna kick me? That's rude...");

                return;
            }
            var memberToKick = userToKick.GetMember(channel.Guild);

            try
            {
                await memberToKick.KickAsync();
            }
            catch (HttpException)
            {
                await ChatMessage.SendError(message, "I cannot kick that person!");

                return;
            }
            await ChatMessage.SendReply(message, $"{userToKick.Username} has been kicked.");
        }
Пример #3
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;
            var channel = message.Channel;

            if (!AkyBot.HasPermission(channel, GuildPermission.EmbedLinks))
            {
                await ChatMessage.SendError(message, "I don't have Embed Links Permission!");

                return;
            }
            var args  = ChatMessage.Args;
            var user1 = ChatMessage.FindUser(0);
            var user2 = ChatMessage.FindUser(1);

            if (user1 == null || user2 == null)
            {
                await ChatMessage.SendError(message, "you have to type or mention 2 users!");

                return;
            }
            var name1 = user1.Username;
            var name2 = user2.Username;

            if (name1 == name2)
            {
                await ChatMessage.SendError(message, "both names cannot be equal.");

                return;
            }
            ulong[] ids = new ulong[] { user1.Id, user2.Id };
            Array.Sort(ids);
            int  score  = 0;
            bool exists = await AkyBot.Databases.LoveCalculator.ContainsNames(ids);

            if (exists)
            {
                score = await AkyBot.Databases.LoveCalculator.GetScore(ids);
            }
            else
            {
                score = GenerateScore();
                await AkyBot.Databases.LoveCalculator.AddNames(ids, score);
            }
            string comment     = GetComment(score);
            string resultStr   = $"> **{name1}**\n> **{name2}**\n{score}% - {comment}";
            var    resultEmbed = new EmbedBuilder()
                                 .WithTitle("💗 Calculating 💗")
                                 .WithColor(AkyBot.EmbedColor)
                                 .WithDescription(resultStr);
            await ChatMessage.Send(message, null, resultEmbed.Build());
        }
Пример #4
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;
            var args    = ChatMessage.Args;
            var author  = message.Author;
            var channel = message.Channel as SocketGuildChannel;
            var member  = author.GetMember(channel.Guild);

            if (!member.GuildPermissions.Has(GuildPermission.KickMembers))
            {
                await ChatMessage.SendError(message, "you do not have Kick Members Permission.");

                return;
            }
            if (!AkyBot.HasPermission(channel, GuildPermission.BanMembers, false))
            {
                await ChatMessage.SendError(message, "I do not have Ban Memebers Permission!");

                return;
            }
            var userToBan = ChatMessage.FindUser(args[0]);

            if (userToBan == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            if (userToBan == author)
            {
                await ChatMessage.SendError(message, "you can't ban yourself.");

                return;
            }
            if (userToBan == AkyBot.Client.CurrentUser)
            {
                await ChatMessage.SendError(message, "why do you wanna ban me? That's rude...");

                return;
            }
            var memberToBan = userToBan.GetMember(channel.Guild);
            var banAsync    = memberToBan.BanAsync();

            if (banAsync.Exception != null)
            {
                await ChatMessage.SendError(message, "I cannot ban that person!");

                return;
            }
            await banAsync;
            await ChatMessage.SendReply(message, $"{userToBan.Username} has been banned from {channel.Guild.Name}.");
        }
Пример #5
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;

            if (!AkyBot.HasPermission(message.Channel as SocketGuildChannel, GuildPermission.ManageRoles))
            {
                await ChatMessage.SendError(message, "I don't have Manage Roles Permission!");

                return;
            }
            var args         = ChatMessage.Args;
            var guild        = (message.Channel as SocketGuildChannel).Guild;
            var authorMember = message.Author.GetMember(guild);

            if (!authorMember.GuildPermissions.Has(GuildPermission.ManageRoles))
            {
                await ChatMessage.SendError(message, "you do not have permission to do that!");

                return;
            }
            string search = string.Join(string.Empty, args);
            var    user   = ChatMessage.FindUser(search, false);

            if (user == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            if (user == AkyBot.Client.CurrentUser)
            {
                await ChatMessage.SendError(message, "I'm not even muted.");

                return;
            }
            if (user == message.Author)
            {
                await ChatMessage.SendError(message, "you are not muted.");

                return;
            }
            var member = user.GetMember(guild);

            if (member.GuildPermissions.Has(GuildPermission.Administrator))
            {
                await ChatMessage.SendError(message, "that user is a mod / admin and is not even muted.");

                return;
            }
            IRole muteRole = guild.Roles.ToList().FirstOrDefault(role => role.Name == AkyBot.MuteRoleName);

            if (muteRole == null || (muteRole != null && !member.Roles.ToList().Contains(muteRole)))
            {
                await ChatMessage.SendError(message, "that user is not muted!");

                return;
            }
            RequestOptions opts = new RequestOptions()
            {
                AuditLogReason = "UnMuted"
            };
            await member.RemoveRoleAsync(muteRole, opts);

            await AkyBot.Databases.MutedMembers.RemoveMember(member);

            await ChatMessage.SendReply(message, $"{member.DisplayName()}has been unmuted.");
        }
Пример #6
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;

            if (!AkyBot.HasPermission(message.Channel as SocketGuildChannel, GuildPermission.ManageRoles))
            {
                await ChatMessage.SendError(message, "I don't have Manage Roles Permission!");

                return;
            }
            var args         = ChatMessage.Args;
            var guild        = (message.Channel as SocketGuildChannel).Guild;
            var authorMember = message.Author.GetMember(guild);

            if (!authorMember.GuildPermissions.Has(GuildPermission.ManageRoles))
            {
                await ChatMessage.SendError(message, "you do not have permission to do that!");

                return;
            }
            string search = string.Join(string.Empty, args);
            var    user   = ChatMessage.FindUser(search, false);

            if (user == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            if (user == AkyBot.Client.CurrentUser)
            {
                await ChatMessage.SendError(message, "you can't mute me.");

                return;
            }
            if (user == message.Author)
            {
                await ChatMessage.SendError(message, "you can't mute yourself.");

                return;
            }
            var member = user.GetMember(guild);

            if (member.GuildPermissions.Has(GuildPermission.Administrator))
            {
                await ChatMessage.SendError(message, "that user is a mod / admin and connot be muted!");

                return;
            }
            IRole muteRole = guild.Roles.ToList().FirstOrDefault(role => role.Name == AkyBot.MuteRoleName);

            if (muteRole != null && member.Roles.ToList().Contains(muteRole))
            {
                await ChatMessage.SendError(message, "that user is already muted.");

                return;
            }
            if (muteRole == null)
            {
                muteRole = await guild.CreateRoleAsync(AkyBot.MuteRoleName, new GuildPermissions());

                var channels = guild.Channels.ToList();
                for (int i = 0; i < channels.Count; i++)
                {
                    var channel = channels[i];
                    await channel.AddPermissionOverwriteAsync(muteRole, new OverwritePermissions(sendMessages : PermValue.Deny, addReactions : PermValue.Deny));
                }
            }
            RequestOptions opts = new RequestOptions()
            {
                AuditLogReason = "Muted"
            };
            await member.AddRoleAsync(muteRole, opts);

            await ChatMessage.SendReply(message, $"{member.DisplayName()} has been muted.");
        }
Пример #7
0
        public override async Task Execute()
        {
            var message = ChatMessage.Current;
            var channel = message.Channel;

            if (!AkyBot.HasPermission(channel, GuildPermission.EmbedLinks))
            {
                await ChatMessage.SendError(message, "I don't have Embed Links Permission!");

                return;
            }

            var user = ChatMessage.FindUser(0, true);

            if (user == null)
            {
                await ChatMessage.SendError(message, "user cannot be found!");

                return;
            }
            if (user == AkyBot.Client.CurrentUser)
            {
                await new BotInfo().Execute();
                return;
            }
            var id          = user.Id.ToString();
            var guild       = (channel as SocketGuildChannel).Guild;
            var member      = user.GetMember(guild);
            var tag         = user.Tag();
            var nickname    = member.Nickname;
            var dateCreated = user.CreatedAt.ToString("f", DateTimeFormatInfo.CurrentInfo);
            var dateJoined  = member.JoinedAt.Value.ToString("f", DateTimeFormatInfo.CurrentInfo);
            var status      = user.Status.ToString();
            var activity    = string.Empty;

            if (user.Activity != null)
            {
                activity = user.Activity.Type.ToString() + ' ' + user.Activity.Name;
            }
            var memberRoles = member.Roles.ToList();

            memberRoles.Remove(memberRoles.Single(role => role == guild.EveryoneRole));
            var rolesList = memberRoles.Select(role => role.Name).ToList();

            rolesList.Sort();
            var roles = string.Join(", ", rolesList);

            if (rolesList.Count == 0)
            {
                roles = "None";
            }
            var embed = new EmbedBuilder();

            embed.WithTitle("- User Info -");
            embed.AddField("Username:"******"Nickname:", nickname);
            }
            embed.AddField("Date Created:", dateCreated)
            .AddField("Date Joined:", dateJoined)
            .AddField("Status:", status);
            if (activity != string.Empty)
            {
                embed.AddField("Activity:", activity);
            }
            embed.AddField("Roles:", roles);
            embed.WithFooter($"ID: {id}");
            embed.WithColor(AkyBot.EmbedColor);
            embed.WithThumbnailUrl(user.DisplayAvatarURL());
            await ChatMessage.Send(message, null, embed.Build());
        }