示例#1
0
        public async Task getPP(params String[] UserL)
        {
            string output = new Addons()._out(UserL);

            if (output != "")
            {
                if (output.IndexOf('@') == 1)
                {
                    try
                    {
                        output = output.Remove(0, 2);
                        output = output.Remove(output.Length - 1, 1);
                        if (output.IndexOf('!') == 0)
                        {
                            output = output.Remove(0, 1);
                        }
                        SocketGuildUser j = null;
                        var             n = Initialization._client.Guilds.GetEnumerator();
                        n.MoveNext();
                        var g = n.Current;
                        for (int i = 0; i < Initialization._client.Guilds.Count; i++)
                        {
                            g = n.Current;
                            n.MoveNext();
                            if (j == null)
                            {
                                j = g.Users.FirstOrDefault(x => x.Id == ulong.Parse(output));
                            }
                        }
                        if (j == null)
                        {
                            throw new Exception();
                        }
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512));
                        eb.WithColor(40, 200, 150);
                        eb.AddField($"{j.Username}#{j.Discriminator}", $"[Avatar URL]({j.GetAvatarUrl(ImageFormat.Auto, 512)})", true);
                        eb.WithImageUrl(j.GetAvatarUrl());
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                    catch (Exception)
                    {
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                        eb.WithColor(40, 200, 150);
                        eb.AddField("Exception details", $"**Can't find user with id {output} in all connected to the bot servers.**");
                        eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                }
                else
                {
                    try
                    {
                        var n = Initialization._client.Guilds.GetEnumerator();
                        n.MoveNext();
                        var             g = n.Current;
                        SocketGuildUser j = null;
                        for (int i = 0; i < Initialization._client.Guilds.Count; i++)
                        {
                            g = n.Current;
                            n.MoveNext();
                            if (j == null)
                            {
                                j = g.Users.FirstOrDefault(x => x.Username == output);
                            }
                        }
                        if (j == null)
                        {
                            throw new Exception();
                        }
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512));
                        eb.WithColor(40, 200, 150);
                        eb.AddField($"{j.Username}#{j.Discriminator}", $"[Avatar URL]({j.GetAvatarUrl(ImageFormat.Auto, 512)})", true);
                        eb.WithImageUrl(j.GetAvatarUrl());
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                    catch (Exception)
                    {
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                        eb.WithColor(40, 200, 150);
                        eb.AddField("Exception details", $"**Can't find user with username \"{output}\" in all connected to the bot servers.**");
                        eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                }
            }
            else
            {
                EmbedBuilder eb = new EmbedBuilder();
                eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), Context.User.GetAvatarUrl());
                eb.WithColor(40, 200, 150);
                eb.AddField($"{Context.User.Username}#{Context.User.Discriminator}", $"[Avatar URL]({Context.User.GetAvatarUrl(ImageFormat.Auto, 512)})", true);
                eb.WithImageUrl(Context.User.GetAvatarUrl());
                await Context.Channel.SendMessageAsync("", false, eb.Build());
            }
        }
示例#2
0
        public async Task UserInfo(params String[] UserL)
        {
            if (Context.IsPrivate)
            {
                return;
            }
            string output = new Addons()._out(UserL);

            if (output != "")
            {
                if (output.IndexOf('@') == 1)
                {
                    try
                    {
                        output = output.Remove(0, 2);
                        output = output.Remove(output.Length - 1, 1);
                        if (output.IndexOf('!') == 0)
                        {
                            output = output.Remove(0, 1);
                        }
                        SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Id == ulong.Parse(output));
                        if (j == null)
                        {
                            throw new Exception();
                        }
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"{j.Username}#{j.DiscriminatorValue}", j.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512));
                        eb.WithColor(40, 200, 150);
                        eb.WithThumbnailUrl(j.GetAvatarUrl());
                        eb.AddField("User ID", $"{j.Id}", true);
                        eb.AddField("Status", $"{j.Status}", true);
                        string nick = "";
                        if (j.Nickname == null)
                        {
                            nick = "None";
                        }
                        else
                        {
                            nick = j.Nickname;
                        }
                        eb.AddField("Nickname", nick);
                        eb.AddField("Registered at", $"{j.CreatedAt.UtcDateTime}");
                        eb.AddField("Joined at", $"{j.JoinedAt.Value.UtcDateTime}");
                        string roles = "";
                        foreach (var role in j.Roles)
                        {
                            if (role.Name != "@everyone")
                            {
                                roles += role.Name;
                                roles += Environment.NewLine;
                            }
                        }
                        eb.AddField($"Roles [{j.Roles.Count -1}]", roles);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                    catch (Exception)
                    {
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                        eb.WithColor(40, 200, 150);
                        eb.AddField("Exception details", $"**Can't find user with id {output} on the server.**");
                        eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                }
                else
                {
                    try
                    {
                        SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Username == output);
                        if (j == null)
                        {
                            throw new Exception();
                        }
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"{j.Username}#{j.DiscriminatorValue}", j.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512));
                        eb.WithColor(40, 200, 150);
                        eb.WithThumbnailUrl(j.GetAvatarUrl());
                        eb.AddField("User ID", $"{j.Id}", true);
                        eb.AddField("Status", $"{j.Status}", true);
                        string nick = "";
                        if (j.Nickname == null)
                        {
                            nick = "None";
                        }
                        else
                        {
                            nick = j.Nickname;
                        }
                        eb.AddField("Nickname", nick);
                        eb.AddField("Registered at", $"{j.CreatedAt.UtcDateTime}");
                        eb.AddField("Joined at", $"{j.JoinedAt.Value.UtcDateTime}");
                        string roles = "";
                        foreach (var role in j.Roles)
                        {
                            if (role.Name != "@everyone")
                            {
                                roles += role.Name;
                                roles += Environment.NewLine;
                            }
                        }
                        eb.AddField($"Roles [{j.Roles.Count -1}]", roles);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                    catch (Exception)
                    {
                        EmbedBuilder eb = new EmbedBuilder();
                        eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                        eb.WithColor(40, 200, 150);
                        eb.AddField("Exception details", $"**Can't find user with username \"{output}\" on the server.**");
                        eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                        await Context.Channel.SendMessageAsync("", false, eb.Build());

                        return;
                    }
                }
            }
            else
            {
                EmbedBuilder eb = new EmbedBuilder();
                eb.WithAuthor($"{Context.User.Username}#{Context.User.DiscriminatorValue}", Context.User.GetAvatarUrl(), Context.User.GetAvatarUrl(ImageFormat.Auto, 512));
                eb.WithColor(40, 200, 150);
                eb.WithThumbnailUrl(Context.User.GetAvatarUrl());
                eb.AddField("User ID", $"{Context.User.Id}", true);
                eb.AddField("Status", $"{Context.User.Status}", true);
                string nick = "";
                if (Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Nickname == null)
                {
                    nick = "None";
                }
                else
                {
                    nick = Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Nickname;
                }
                eb.AddField("Nickname", nick);
                eb.AddField("Registered at", $"{Context.User.CreatedAt.UtcDateTime}");
                eb.AddField("Joined at", $"{Context.Guild.CurrentUser.JoinedAt.Value.UtcDateTime}");
                string roles = "";
                foreach (var role in Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Roles)
                {
                    if (role.Name != "@everyone")
                    {
                        roles += role.Name;
                        roles += Environment.NewLine;
                    }
                }
                eb.AddField($"Roles [{Context.Guild.CurrentUser.Roles.Count -1}]", roles);
                await Context.Channel.SendMessageAsync("", false, eb.Build());

                return;
            }
        }
示例#3
0
        public async Task ServerInfo(params String[] guildName)
        {
            if (Context.IsPrivate == true)
            {
                if (guildName.Length <= 0)
                {
                    EmbedBuilder eb1 = new EmbedBuilder();
                    eb1.WithAuthor("Error", Context.User.GetAvatarUrl());
                    eb1.WithColor(40, 200, 150);
                    eb1.WithDescription("**Please use this command only in a server to get it's info, or get an info about another server here.**");
                    eb1.WithThumbnailUrl(Settings.MainThumbnailUrl);
                    await Context.User.SendMessageAsync("", false, eb1.Build());

                    return;
                }
            }

            SocketGuild guild  = Context.Guild;
            string      output = new Addons()._out(guildName);

            if (guildName.Length >= 1 && guildName.ElementAt(0) == "roles")
            {
                output = output.Remove(0, 5);
                if (guildName.Length > 1)
                {
                    output = output.Remove(0, 1);
                    guild  = Context.Client.Guilds.Where(x => x.Name == output).FirstOrDefault();
                }
                EmbedBuilder eb1 = new EmbedBuilder();
                eb1.WithAuthor($"{guild.Name} roles ({guild.Roles.Count})", guild.IconUrl);
                eb1.WithColor(40, 200, 150);
                string roles = "";
                for (int i = 0; i < guild.Roles.Count; i++)
                {
                    roles += guild.Roles.ElementAt(i);
                    roles += Environment.NewLine;
                }
                eb1.WithDescription(roles);
                await Context.Channel.SendMessageAsync("", false, eb1.Build());

                return;
            }

            if (output != null)
            {
                guild = Initialization._client.Guilds.Where(x => x.Name == output).FirstOrDefault();
            }
            if (guild == null)
            {
                EmbedBuilder eb2 = new EmbedBuilder();
                eb2.WithAuthor($"Error", Context.User.GetAvatarUrl());
                eb2.WithColor(40, 200, 150);
                eb2.WithDescription($":x: **Can't find guild with name: {output}**");
                eb2.WithThumbnailUrl(Settings.MainThumbnailUrl);
                await Context.Channel.SendMessageAsync("", false, eb2.Build());
            }
            EmbedBuilder eb = new EmbedBuilder();

            eb.WithAuthor($"{guild.Name}", guild.IconUrl);
            eb.WithColor(40, 200, 150);
            eb.AddField($"ID: {guild.Id}", $"[Server avatar]({guild.IconUrl})");
            eb.AddField("Verification Level", $"{guild.VerificationLevel}", true);
            eb.AddField("Region", $"{guild.VoiceRegionId}", true);
            eb.AddField("Members", $"{guild.MemberCount} members", true);
            eb.AddField("Channels", $"{guild.Channels.Count}", true);
            eb.AddField("Server Owner", $"{guild.Owner.Username}#{guild.Owner.Discriminator} | ID: {guild.OwnerId}");
            eb.AddField("Created at", $"{guild.CreatedAt.UtcDateTime}");
            eb.AddField("Roles", $"{guild.Roles.Count} roles");
            eb.WithFooter("Use d!server roles to show all roles.", guild.IconUrl);
            eb.WithThumbnailUrl($"{guild.IconUrl}");
            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
示例#4
0
        public async Task ban(string reason, params String[] UserL)
        {
            var user = Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username);

            if (user.GuildPermissions.BanMembers == true)
            {
                string output = new Addons()._out(UserL);
                if (output != "")
                {
                    if (output.IndexOf('@') == 1)
                    {
                        try
                        {
                            output = output.Remove(0, 2);
                            output = output.Remove(output.Length - 1, 1);
                            if (output.IndexOf('!') == 0)
                            {
                                output = output.Remove(0, 1);
                            }
                            SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Id == ulong.Parse(output));
                            if (j == null)
                            {
                                throw new Exception();
                            }
                            if (j.Username == "Ducky Bot" && j.DiscriminatorValue == 5489 && j.IsBot == true)
                            {
                                await Context.Channel.SendMessageAsync("You can't ban Ducky Bot!");

                                return;
                            }
                            if (j == user)
                            {
                                await Context.Channel.SendMessageAsync("You can't ban yourself!");

                                return;
                            }
                            if (user.Hierarchy < j.Hierarchy)
                            {
                                await Context.Channel.SendMessageAsync("Your role is under the user role!");

                                return;
                            }
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Successful");
                            eb.WithColor(40, 200, 150);
                            eb.WithThumbnailUrl(j.GetAvatarUrl());
                            eb.WithDescription($"**{j.Username} has been banned**");
                            eb.AddField("Reason", reason);
                            eb.AddField("Banned by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}");
                            await Context.Guild.AddBanAsync(j, 0, reason);

                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                        catch (Discord.Net.HttpException)
                        {
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                            eb.WithColor(40, 200, 150);
                            eb.AddField("Exception details", $"**Bot role is under the user role**");
                            eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                        catch (Exception)
                        {
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                            eb.WithColor(40, 200, 150);
                            eb.AddField("Exception details", $"**Can't find user with id {output} in the server.**");
                            eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                    }
                    else
                    {
                        try
                        {
                            SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Username == output);
                            if (j == null)
                            {
                                throw new Exception();
                            }
                            if (user.Hierarchy < j.Hierarchy)
                            {
                                await Context.Channel.SendMessageAsync("Your role is under the user role!");

                                return;
                            }
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Successful");
                            eb.WithColor(40, 200, 150);
                            eb.WithThumbnailUrl(j.GetAvatarUrl());
                            eb.WithDescription($"**{j.Username} has been banned**");
                            eb.AddField("Reason", reason);
                            eb.AddField("Banned by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}");
                            await Context.Guild.AddBanAsync(j, 0, reason);

                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                        catch (Discord.Net.HttpException)
                        {
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                            eb.WithColor(40, 200, 150);
                            eb.AddField("Exception details", $"**Bot role is under the user role**");
                            eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                        catch (Exception)
                        {
                            EmbedBuilder eb = new EmbedBuilder();
                            eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                            eb.WithColor(40, 200, 150);
                            eb.AddField("Exception details", $"**Can't find user with username \"{output}\" in the server.**");
                            eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                            await Context.Channel.SendMessageAsync("", false, eb.Build());

                            return;
                        }
                    }
                }
                else
                {
                    EmbedBuilder eb = new EmbedBuilder();
                    eb.WithAuthor($"Error", Context.User.GetAvatarUrl());
                    eb.WithColor(40, 200, 150);
                    eb.WithDescription("**Please use correct reason and username**");
                    eb.WithThumbnailUrl(Settings.MainThumbnailUrl);
                    await Context.Channel.SendMessageAsync("", false, eb.Build());
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync("You don't have \"Ban Members\" permission to use this command!");
            }
        }