Beispiel #1
0
        public async Task RoleShopAddRole(int price, [Remainder] string name = "")
        {
            if (price < 0)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared($"~ Price can't be negative ~")
                                                       .WithColor(Color.DarkRed)
                                                       .Build());

                return;
            }

            var role = await this.SelectRole(name);

            if (role == null)
            {
                return;
            }


            int userHigh = ((SocketGuildUser)Context.User).Roles.Max(x => x.Position);

            if (userHigh <= role.Position)
            {
                await Context.Channel.SendMessageAsync($":x: You do not have permission to modify `{role.Name}`! Make sure you have a role higher in the list.");

                return;
            }

            if (await ShopRoleDb.IsRole(role.Id))
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared($"~ **{role.Name}** is already in the shop ~")
                                                       .WithColor(Color.DarkRed)
                                                       .Build());

                return;
            }

            await ShopRoleDb.AddRole(Context.Guild.Id, role.Id, price);

            await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared($"~ **{role.Name}** added to the shop ~").Build());
        }