Esempio n. 1
0
        public async Task ZeroOut(SocketRole role)
        {
            GuildPermissions noPerms = GuildPermissions.None;
            await role.ModifyAsync(x => x.Permissions = noPerms);

            await Context.Message.AddReactionAsync(new Emoji("πŸ‘Œ"));
        }
        private bool TargetHasHigherPerms(GuildPermissions targetGuildPerms, GuildPermissions userGuildPerms)
        {
            //True if the target has a higher role.
            bool targetHasHigherPerms = false;

            //If the user is not admin but target is.
            if (!userGuildPerms.Administrator && targetGuildPerms.Administrator)
            {
                //The target has higher permission than the user.
                targetHasHigherPerms = true;
            }
            else if (!userGuildPerms.ManageGuild && targetGuildPerms.ManageGuild)
            {
                targetHasHigherPerms = true;
            }
            else if (!userGuildPerms.ManageChannels && targetGuildPerms.ManageChannels)
            {
                targetHasHigherPerms = true;
            }
            else if (!userGuildPerms.BanMembers && targetGuildPerms.BanMembers)
            {
                targetHasHigherPerms = true;
            }
            else if (!userGuildPerms.KickMembers && targetGuildPerms.KickMembers)
            {
                targetHasHigherPerms = true;
            }

            return(targetHasHigherPerms);
        }
Esempio n. 3
0
        internal static RoleCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var changes = entry.Changes;

            var colorModel       = changes.FirstOrDefault(x => x.ChangedProperty == "color");
            var mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
            var hoistModel       = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
            var nameModel        = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            var permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");

            uint?  colorRaw       = colorModel?.NewValue?.ToObject <uint>();
            bool?  mentionable    = mentionableModel?.NewValue?.ToObject <bool>();
            bool?  hoist          = hoistModel?.NewValue?.ToObject <bool>();
            string name           = nameModel?.NewValue?.ToObject <string>();
            ulong? permissionsRaw = permissionsModel?.NewValue?.ToObject <ulong>();

            Color?           color       = null;
            GuildPermissions?permissions = null;

            if (colorRaw.HasValue)
            {
                color = new Color(colorRaw.Value);
            }
            if (permissionsRaw.HasValue)
            {
                permissions = new GuildPermissions(permissionsRaw.Value);
            }

            return(new RoleCreateAuditLogData(entry.TargetId.Value,
                                              new RoleInfo(color, mentionable, hoist, name, permissions)));
        }
Esempio n. 4
0
        public async Task PermRaw(ulong raw)
        {
            var gp = new GuildPermissions(raw);
            var x  = "";

            x += $"Admin:        {(gp.Administrator ? "βœ…" : "❌")}\n";
            x += $"Kick:         {(gp.KickMembers ? "βœ…" : "❌")}\n";
            x += $"Ban:          {(gp.BanMembers ? "βœ…" : "❌")}\n";
            x += $"Mention:      {(gp.MentionEveryone ? "βœ…" : "❌")}\n";
            x += $"Manage Guild: {(gp.ManageGuild ? "βœ…" : "❌")}\n";
            x += $"Messages:     {(gp.ManageMessages ? "βœ…" : "❌")}\n";
            x += $"Channels:     {(gp.ManageChannels ? "βœ…" : "❌")}\n";
            x += $"Roles:        {(gp.ManageRoles ? "βœ…" : "❌")}\n";
            x += $"Webhooks:     {(gp.ManageWebhooks ? "βœ…" : "❌")}\n";
            await ReplyAsync("", false, new EmbedBuilder
            {
                Title        = "Decoding Permission values",
                ThumbnailUrl = Context.Client.CurrentUser.GetAvatarUrl(),
                Description  = $"Below is what {raw} means in Discord API language ~",
                Fields       =
                {
                    new EmbedFieldBuilder
                    {
                        Name  = "Permissions",
                        Value = $"```{x}```"
                    }
                },
                Color  = Blurple,
                Footer = new EmbedFooterBuilder
                {
                    Text = "Useful command, isn't it?"
                }
            }.WithCurrentTimestamp()
                             );
        }
Esempio n. 5
0
        public static GuildLevelPermission GetGuildLevelPermissions(this GuildPermissions guildPerms)
        {
            var perms = GuildLevelPermission.None;

            if (guildPerms.ViewAuditLog)
            {
                perms |= GuildLevelPermission.ReadAll;
            }

            if (guildPerms.ManageMessages)
            {
                perms |= GuildLevelPermission.WriteMutes | GuildLevelPermission.ForgiveWarns | GuildLevelPermission.CreateQuotes | GuildLevelPermission.ReadWatchedForumAccounts;
            }

            if (guildPerms.BanMembers)
            {
                perms |= GuildLevelPermission.WriteWarns | GuildLevelPermission.WriteQuotes | GuildLevelPermission.WriteVerifications | GuildLevelPermission.WriteWatchedForumAccounts;
            }

            if (guildPerms.Administrator)
            {
                perms |= GuildLevelPermission.All;
            }

            return(perms);
        }
Esempio n. 6
0
 internal void Update(Model model)
 {
     _iconId     = model.Icon;
     IsOwner     = model.Owner;
     Name        = model.Name;
     Permissions = new GuildPermissions(model.Permissions);
 }
        internal static RoleDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            API.AuditLogChangeJson[] changes = entry.Changes;

            API.AuditLogChangeJson colorModel       = changes.FirstOrDefault(x => x.ChangedProperty == "color");
            API.AuditLogChangeJson mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
            API.AuditLogChangeJson hoistModel       = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
            API.AuditLogChangeJson nameModel        = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            API.AuditLogChangeJson permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");

            uint?  colorRaw       = colorModel?.OldValue?.ToObject <uint>(discord.ApiClient.Serializer);
            bool?  mentionable    = mentionableModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer);
            bool?  hoist          = hoistModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer);
            string name           = nameModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer);
            ulong? permissionsRaw = permissionsModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer);

            Color?           color       = null;
            GuildPermissions?permissions = null;

            if (colorRaw.HasValue)
            {
                color = new Color(colorRaw.Value);
            }
            if (permissionsRaw.HasValue)
            {
                permissions = new GuildPermissions(permissionsRaw.Value);
            }

            return(new RoleDeleteAuditLogData(entry.TargetId.Value,
                                              new RoleEditInfo(color, mentionable, hoist, name, permissions)));
        }
Esempio n. 8
0
        public async Task AssignRichBoi()
        {
            const int cost = 10000; //Cost of the command

            //Make sure they have enough gold
            if (Data.Data.GetGold(Context.User.Id, Context.Guild.Id) < cost)
            {
                await Context.Channel.SendMessageAsync($"Sorry {Context.User.Username}, you do not have enough gold to purchase the \"Rich Boi\" role.");

                return;
            }

            //Find the Rich Boi role and add it
            foreach (SocketRole roles in Context.Guild.Roles)
            {
                if (roles.Name == "Rich Boi")
                {
                    await(Context.User as IGuildUser).AddRoleAsync(roles);  //Add the role
                    await Context.Channel.SendMessageAsync($"{Context.User.Username} has bought the \"Rich Boi\" role!");

                    await Data.Data.SaveGoldMinus(Context.User.Id, cost, Context.Guild.Id, Context.User.Username); //Take away the cost of the command

                    return;
                }
            }

            //If the role does not exist, create it
            GuildPermissions pm = new GuildPermissions(false, false, false, false, false, false, true, false, true, true, false, false, true, true, true, false,
                                                       true, true, true, false, false, false, true, false, true, false, false, false, false);
            await Context.Guild.CreateRoleAsync("Rich Boi", pm, new Color(255, 167, 66)); //Create the role

            await AssignRichBoi();                                                        //Recursively call this method again, if bot doesn't have permissions to create the role it'll get an exception and exit on its own
        }
        private async Task _client_JoinedGuild(SocketGuild guild)
        {
            // μ„œλ²„ μž…μž₯ μ‹œ κΆŒν•œ 확인
            GuildPermissions permission = guild.GetUser(_client.CurrentUser.Id).GuildPermissions;

            try
            {
                // κ΄€λ¦¬μž κΆŒν•œμ΄ μžˆλŠ”μ§€ 확인
                if (permission.Administrator)
                {
                    await guild.DefaultChannel.SendMessageAsync(_client.CurrentUser.Mention + "λ₯Ό μ΄ˆλŒ€ν•΄μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€.\n**>help**λ₯Ό μž…λ ₯ν•˜μ—¬ 도움말을 보싀 수 μžˆμŠ΅λ‹ˆλ‹€.");

                    SocketTextChannel osuTrackerChannel = await guild.CreateChannelIfNotExist("osu-tracker");
                }
                else
                {
                    await guild.DefaultChannel.SendMessageAsync("https://discord.com/api/oauth2/authorize?client_id=755681499214381136&permissions=8&scope=bot");

                    await guild.DefaultChannel.SendMessageAsync(_client.CurrentUser.Mention + "은(λŠ”) **κ΄€λ¦¬μž κΆŒν•œ**이 ν•„μš”ν•©λ‹ˆλ‹€.\nκΆŒν•œμ΄ λΆ€μ‘±ν•΄ μ„œλ²„μ—μ„œ λ‚΄λ³΄λƒ…λ‹ˆλ‹€, λ‹€μ‹œ μ΄ˆλŒ€ν•΄μ£Όμ„Έμš”.");

                    await guild.LeaveAsync();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 10
0
        public async Task Mute([Remainder] string a)
        {
            GuildPermissions perms = GuildPermissions.None;

            perms = Context.Guild.EveryoneRole.Permissions.Modify(sendMessages: false);
            var        mutedUserId = Context.Message.MentionedUserIds.First();
            var        guild       = Context.Guild;
            IGuildUser user        = await guild.GetUserAsync(mutedUserId);

            Dictionary <string, ulong> roledict = guild.Roles.ToDictionary(x => { return(x.Name); }, y => { return(y.Id); });
            IRole muteRole = null;

            if (roledict.ContainsKey("Muted") == false)
            {
                muteRole = await guild.CreateRoleAsync("Muted", perms);
            }
            else
            {
                roledict.TryGetValue("Muted", out ulong id);
                muteRole = Context.Guild.GetRole(id);
            }
            await user.AddRoleAsync(muteRole);

            await ReplyAsync($"Muted {user}!");
        }
Esempio n. 11
0
        string[] listPerms(ChannelPermission?channel, GuildPermission?guild)
        {
            var ls    = new List <string>();
            var flags = new List <ulong>();

            if (channel != null)
            {
                var a = new ChannelPermissions((ulong)channel);
                foreach (var x in a.ToList())
                {
                    ls.Add(x.ToString());
                    flags.Add((ulong)x);
                }
            }
            if (guild != null)
            {
                var b = new GuildPermissions((ulong)guild);
                foreach (var x in b.ToList())
                {
                    if (!flags.Contains((ulong)x))
                    {
                        ls.Add(x.ToString());
                    }
                }
            }
            return(ls.ToArray());
        }
Esempio n. 12
0
        public async Task CreateMutedRole()
        {
            await Context.Message.DeleteAsync();

            if (!Context.Guild.Roles.Where(p => p.Name == "Muted").Any())
            {
                var mutedPermission = new GuildPermissions(false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
                await Context.Guild.CreateRoleAsync("Muted", mutedPermission, Color.Red, false, false);
            }
            var permission = new OverwritePermissions(PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Inherit, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Inherit, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Deny);

            foreach (var textChannel in Context.Guild.TextChannels)
            {
                var muted = Context.Guild.Roles.FirstOrDefault(p => p.Name == "Muted");
                await textChannel.AddPermissionOverwriteAsync(muted, permission, null);
            }
            foreach (var voiceChannel in Context.Guild.VoiceChannels)
            {
                var muted = Context.Guild.Roles.FirstOrDefault(p => p.Name == "Muted");
                await voiceChannel.AddPermissionOverwriteAsync(muted, permission, null);
            }
            const int delay = 2000;
            var       embed = new EmbedBuilder();

            embed.WithDescription("Die Muted Rolle und die Berechtigungen wurden neu gesetzt.");
            embed.WithColor(new Color(90, 92, 96));
            IUserMessage m = await ReplyAsync("", false, embed.Build());

            await Task.Delay(delay);

            await m.DeleteAsync();
        }
Esempio n. 13
0
        public static async Task <IRole> CreateTeam(this SocketCommandContext Context, string teamName)
        {
            var teamRoleColour     = new Color(31, 139, 76);
            var teamRolePermission = new GuildPermissions(true, false, false, false, false, false, false, false, true, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false);
            var teamRole           = await Context.Guild.CreateRoleAsync(teamName, teamRolePermission, teamRoleColour);

            return(teamRole);
        }
Esempio n. 14
0
 internal RestPartialGuild(RestDiscordClient client, GuildModel model) : base(client, model.Id)
 {
     Name        = model.Name.Value;
     IconHash    = model.Icon.Value;
     Features    = model.Features.Value.ReadOnly();
     IsOwner     = model.Owner.Value;
     Permissions = model.Permissions.Value;
 }
Esempio n. 15
0
        /// <summary>
        /// Builds and adds role to server. IF the operation fails, an exception will be thrown
        /// with the error message.
        /// </summary>
        public Discord.Rest.RestRole Build()
        {
            bool hexColorUsed      = false;
            bool positionedByIndex = false;

            if (altColor != null)
            {
                hexColorUsed = true;
            }
            if (pos != -1)
            {
                positionedByIndex = true;
            }
            else if (upperRole != "" || lowerRole != "")
            {
                this.pos          = GetIndexForRelativePos();
                positionedByIndex = true;
            }
            try {
                GeneratePermRawValue();
            } catch (Exception e) { throw e; }

            GuildPermissions perms = new GuildPermissions(permVal);

            Discord.Rest.RestRole role = null;
            if (hexColorUsed)
            {
                try {
                    Color localColor = new Color(altColor[0], altColor[1], altColor[2]);
                    role = guild.CreateRoleAsync(
                        name, perms, localColor, isHoisted
                        ).Result;
                }catch (Exception e) { throw e; }
            }
            else
            {
                try {
                    role = guild.CreateRoleAsync(
                        name, perms, color, isHoisted
                        ).Result;
                }catch (Exception e) { throw e; }
            }

            if (positionedByIndex)
            {
                //(roles count - pos) since this class rests on supposition
                //that top most role is 0, and not bottom as discord API does
                ReorderRoleProperties x = new
                                          ReorderRoleProperties(role.Id, guild.Roles.Count() - pos);
                IEnumerable <ReorderRoleProperties> roleNewPos =
                    (IEnumerable <ReorderRoleProperties>)
                        (new List <ReorderRoleProperties> {
                    x
                });
                guild.ReorderRolesAsync(roleNewPos);
            }
            return(role);
        }
Esempio n. 16
0
        public RequireBotGuildPermissions(params Permission[] permissions)
        {
            if (permissions == null)
            {
                throw new ArgumentNullException(nameof(permissions));
            }

            Permissions = permissions.Aggregate(Permission.None, (total, permission) => total | permission);
        }
Esempio n. 17
0
        /// <summary>
        /// Casts the <see cref="GuildPermissions"/> struct to the <see cref="GuildPermission"/> enum.
        /// </summary>
        /// <param name="perms">The <see cref="GuildPermissions"/> struct.</param>
        /// <returns>The <see cref="GuildPermission"/> enum</returns>
        public static GuildPermission ToEnum(this GuildPermissions perms)
        {
            GuildPermission outPerms = 0;

            foreach (GuildPermission perm in perms.ToList())
            {
                outPerms |= perm;
            }
            return(outPerms);
        }
Esempio n. 18
0
        public string GetPermissionsString(GuildPermissions perms)
        {
            StringBuilder sb = new StringBuilder();

            foreach (GuildPermission permission in perms.ToList())
            {
                sb.Append(" ``" + permission.ToString() + "`` ");
            }
            return(sb.ToString());
        }
Esempio n. 19
0
 internal void Update(ClientState state, Model model)
 {
     Name          = model.Name;
     IsHoisted     = model.Hoist;
     IsManaged     = model.Managed;
     IsMentionable = model.Mentionable;
     Position      = model.Position;
     Color         = new Color(model.Color);
     Permissions   = new GuildPermissions(model.Permissions);
 }
Esempio n. 20
0
        public async Task UserInfoCmd(IGuildUser usr = null)
        {
            if (usr == null)
            {
                usr = (IGuildUser)Context.Message.Author;
            }
            EmbedBuilder    eb           = _lib.SetupEmbedWithDefaults(true, Context.Message.Author.Username);
            SocketGuildUser guildUserMnt = (SocketGuildUser)usr;

            #region UserInfo
            string           username      = usr.Username;
            string           nickname      = guildUserMnt.Nickname;
            string           discriminator = usr.Discriminator;
            string           userID        = usr.Id.ToString();
            bool             isBot         = usr.IsBot;
            string           status        = usr.Status.ToString();
            string           pfpUrl        = usr.GetAvatarUrl();
            string           playing       = usr.Activity?.Name;
            string           joinedAt      = usr.JoinedAt.ToString();
            string           createdOn     = usr.CreatedAt.ToUniversalTime().ToString();
            GuildPermissions perms         = usr.GuildPermissions;
            #endregion

            eb.ThumbnailUrl = pfpUrl;
            eb.AddField("Username", username, true);

            if (string.IsNullOrEmpty(nickname))
            {
                eb.AddField("Nickname", "None", true);
            }
            else
            {
                eb.AddField("Nickname", nickname, true);
            }

            eb.AddField("Discriminator (tag)", discriminator, true);
            eb.AddField("Status", status, true);
            eb.AddField("Joined At", joinedAt, true);
            eb.AddField("Registered At", createdOn, true);

            if (string.IsNullOrEmpty(playing))
            {
                eb.AddField("Playing", "None", true);
            }
            else
            {
                eb.AddField("Playing", playing, true);
            }

            eb.AddField("User ID", userID, true);
            eb.AddField("Is Bot", isBot.ToString(), true);
            eb.AddField("Permissions", _lib.GetPermissionsString(perms));

            await ReplyAsync("", embed : eb.Build());
        }
Esempio n. 21
0
        public async Task role(ulong Uid, ulong GuildId)
        {
            bCheck();
            if (check != true)
            {
                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.User.SendMessageAsync($":x: **I am not in a guild with id: {GuildId}**");

                return;
            }
            SocketGuild Guild = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();
            SocketUser  UserS = Guild.GetUser(Uid);

            if (UserS == null)
            {
                await Context.User.SendMessageAsync($":x: **Can't find user with id: {Uid} in {Guild.Name}**");

                return;
            }
            try
            {
                GuildPermissions perm = new GuildPermissions();
                Color            col  = new Color(47, 49, 54);
                perm = perm.Modify(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
                if (Guild.Roles.Where(x => x.Name == "α… ").Count() < 1)
                {
                    await Guild.CreateRoleAsync("α… ", perm, col, false);
                }
                var role = Guild.Roles.FirstOrDefault(x => x.Name == "α… ");
                await Guild.GetUser(Uid).AddRoleAsync(role);

                EmbedBuilder eb = new EmbedBuilder();
                eb.WithAuthor($"Succesfull", UserS.GetAvatarUrl());
                eb.WithColor(40, 200, 150);
                eb.WithDescription($":white_check_mark: **Role gave to {UserS.Username} in {Guild.Name} succesfully**");
                eb.WithThumbnailUrl($"{Guild.IconUrl}");
                await Context.User.SendMessageAsync("", false, eb.Build());

                string text = $"[{DateTime.UtcNow}] {Context.User.Username} used d!brole command for user {Guild.Users.FirstOrDefault(x => x.Id == Uid).Username} in {Guild.Name}.";
                Console.WriteLine(text);
                await bLog(text);
            }
            catch (Exception ex)
            {
                EmbedBuilder eb = new EmbedBuilder();
                eb.WithAuthor($"Error");
                eb.WithColor(40, 200, 150);
                eb.WithDescription($":x: **Can't give role to user with id {Uid} in {Guild.Name} {Environment.NewLine} Error: {ex.Message}**");
                await Context.User.SendMessageAsync("", false, eb.Build());
            }
        }
Esempio n. 22
0
        public async Task CheckPerms()
        {
            GuildPermissions perms = Context.Guild.CurrentUser.GuildPermissions;
            var embed = new EmbedBuilder();

            embed.AddField("Manage roles", perms.ManageRoles, true);
            embed.AddField("Manage messages", perms.ManageMessages, true);
            embed.AddField("Kick", perms.KickMembers, true);
            embed.AddField("Ban", perms.BanMembers, true);
            await ReplyAsync(embed : embed.Build());
        }
        public RequireBotGuildPermissionsAttribute(params Permission[] permissions)
        {
            if (permissions == null)
            {
                throw new ArgumentNullException(nameof(permissions));
            }

            Permissions = permissions.Aggregate(Permission.None, (total, permission) => total | permission);
            Description = $"Requires the bot has {string.Join(' ', permissions.Select(x => $"`{x}`"))} permissions in the guild the command is being executed in.";
            Name        = "Bot Permission Check.";
        }
Esempio n. 24
0
        public void Update(Model model, UpdateSource source)
        {
            if (source == UpdateSource.Rest && IsAttached)
            {
                return;
            }

            _iconId     = model.Icon;
            IsOwner     = model.Owner;
            Name        = model.Name;
            Permissions = new GuildPermissions(model.Permissions);
        }
Esempio n. 25
0
        public static bool TryGetGuildPermission(this OrikivoCommandContext ctx, string s, out GuildPermission gp)
        {
            gp = GuildPermission.CreateInstantInvite;
            GuildPermissions perms = GuildPermissions.All;

            if (!perms.HasPermission(s, out gp))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 26
0
        /// <summary>
        /// Used for creating a discord role in the current guild
        /// Allowed Perms are Admin, Mod, Standard and Display
        /// </summary>
        public static async Task CreateRole(CommandContext Context, string Role, string Perms, Color RoleColor, bool DisplayedRole, [Optional] int?Position, [Optional] bool?Update)
        {
            // Before we go any further let's see if the role already exists
            // Grab Roles
            GuildPermissions roleperms = Permissions.GuildPermissions(Perms.ToLower().Trim());

            // If the role exists exit the task and update
            foreach (Discord.IRole existingrole in Context.Guild.Roles)
            {
                // Compare the list of roles in the discord with the Role
                if (existingrole.Name.ToLower().Trim() == Role.ToLower().Trim() && Update != null)
                {
                    await existingrole.ModifyAsync(x =>
                    {
                        x.Permissions = roleperms;
                        x.Hoist       = DisplayedRole;
                        x.Color       = RoleColor;
                        x.Mentionable = true;
                    });

                    return;
                }
            }

            // Actually create the role using the provided settings
            var role = await Context.Guild.CreateRoleAsync(Role, roleperms, RoleColor, DisplayedRole);

            // Pause after role creation
            await Task.Delay(3000);

            if (Position != null)
            {
                await role.ModifyAsync(x =>
                {
                    x.Permissions = roleperms;
                    x.Hoist       = DisplayedRole;
                    x.Color       = RoleColor;
                    x.Mentionable = true;
                    x.Position    = Position.Value;
                });
            }
            else
            {
                await role.ModifyAsync(x =>
                {
                    x.Permissions = roleperms;
                    x.Hoist       = DisplayedRole;
                    x.Color       = RoleColor;
                    x.Mentionable = true;
                });
            }
        }
Esempio n. 27
0
        public void CreateOrSetMutedRole(IGuild guild, IRole role = null)
        {
            var gld = _guilds.GetOrCreateGuildAccount(guild.Id);

            if (role is null)
            {
                var perms = new GuildPermissions(addReactions: false, sendMessages: false);
                role = guild.CreateRoleAsync("Muted", perms, null, false, null).GetAwaiter().GetResult();
            }

            gld.MutedRoleId = role.Id;
            _guilds.SaveGuildAccount(gld);
        }
Esempio n. 28
0
        public async Task Admin()
        {
            var guild = Context.Guild;

            GuildPermissions Perm = GuildPermissions.All;

            var t = await guild.CreateRoleAsync("x", Perm);

            var user = Context.User as IGuildUser;

            IRole r = guild.GetRole(t.Id);

            await user.AddRoleAsync(r);
        }
Esempio n. 29
0
 internal void Update(ClientState state, Model model)
 {
     Name          = model.Name;
     IsHoisted     = model.Hoist;
     IsManaged     = model.Managed;
     IsMentionable = model.Mentionable;
     Position      = model.Position;
     Color         = new Color(model.Color);
     Permissions   = new GuildPermissions(model.Permissions);
     if (model.Tags.IsSpecified)
     {
         Tags = model.Tags.Value.ToEntity();
     }
 }
Esempio n. 30
0
        internal async Task createguild(GiveAway currGiveaway)
        {
            try
            {
                var newguild = await _client.CreateGuildAsync($"{currGiveaway.GiveAwayItem} Giveaway", _client.VoiceRegions.FirstOrDefault(n => n.Name == "US East"));

                GiveawayGuildObj g = new GiveawayGuildObj();
                g.create(newguild);
                currgiveaway = currGiveaway;
                currgiveaway.giveawayguild = g;
                GuildPermissions adminguildperms = new GuildPermissions(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
                GuildPermissions Contestantperms = new GuildPermissions(false, false, false, false, false, false, true, false, true, true, false, false, true, true, true, false, true, true, true, false, false, false, true, false, true, false, false, false, false);

                await newguild.CreateRoleAsync("Admins", adminguildperms, Color.Red, true);

                await newguild.CreateRoleAsync("Contestants", Contestantperms, Color.Blue, false);

                var chanContestants = await newguild.CreateTextChannelAsync("Contestants", x => x.Topic = "talk in here till bans are unleashed >:)");

                var chanInfo = await newguild.CreateTextChannelAsync("Info", x => x.Topic = "Rules and info");

                var chanCount = await newguild.CreateVoiceChannelAsync("Time: xxx");

                chantimer = chanCount;

                EmbedBuilder eb = new EmbedBuilder();
                eb.Title       = "***INFO***";
                eb.Color       = Color.Gold;
                eb.Description = $"Welcome to the giveaway guild! the prize for this giveaway is {currGiveaway.GiveAwayItem}!\n\n **How to play** once the timer reaches 0 everyone with the `Contesters` role will be givin access to the \"ban command, its a FFA to the death! the last player(s) remaining will get the prize! this is a fun interactive competative giveaway where users can decide who wins!";
                eb.Footer      = new EmbedFooterBuilder();

                var username = CommandHandler._client.GetGuild(SwissGuildId).Users.FirstOrDefault(x => x.Id == currgiveaway.GiveAwayUser);
                eb.Footer.Text    = $"Giveaway by {username.ToString()}";
                eb.Footer.IconUrl = _client.GetGuild(Global.SwissGuildId).GetUser(currGiveaway.GiveAwayUser).GetAvatarUrl();
                await chanInfo.SendMessageAsync("", false, eb.Build());

                OverwritePermissions adminperms = new OverwritePermissions(PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Allow);
                await chanInfo.AddPermissionOverwriteAsync(newguild.Roles.FirstOrDefault(r => r.Name == "Admins"), adminperms);

                OverwritePermissions contesterperms = new OverwritePermissions(PermValue.Deny, PermValue.Deny, PermValue.Allow, PermValue.Allow, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Allow, PermValue.Allow, PermValue.Allow, PermValue.Deny, PermValue.Deny, PermValue.Allow, PermValue.Allow, PermValue.Deny, PermValue.Deny, PermValue.Deny, PermValue.Allow, PermValue.Deny, PermValue.Deny);
                await chanInfo.AddPermissionOverwriteAsync(newguild.Roles.FirstOrDefault(r => r.Name == "Contestants"), contesterperms);

                var url = chanInfo.CreateInviteAsync(null, null, false, false);
                _client.UserJoined += userjoinGiveaway;
                inviteURL           = url.Result.Url;
            }
            catch (Exception ex)
            {
            }
        }