Beispiel #1
0
        public async Task removeRole(Discord.IRole role)
        {
            //remove a task from the database!
            string result = DBTransaction.removeRole(role.Id);

            await ReplyAsync(result);
        }
Beispiel #2
0
        public async Task addRole(Discord.IRole role, string emoji, ulong messageID)
        {
            //try to give user role in order to test if perms are present
            IGuildUser user = (IGuildUser)Context.Message.Author;

            try
            {
                //if user has it, remove then add back, this prevents removal of roles from people who already had a role
                if (user.RoleIds.Contains(role.Id))
                {
                    await user.RemoveRoleAsync(role);

                    await user.AddRoleAsync(role);
                }
                //if they dont, add it and then remove again
                else
                {
                    await user.AddRoleAsync(role);

                    await user.RemoveRoleAsync(role);
                }
                Console.WriteLine("Successful Role addition test. Permissions ok.");
                //add a task to list
                DBTransaction.setReactionRole(role.Id, Context.Guild.Id, emoji, messageID);
                await ReplyAsync("Success! Reacting with ``" + emoji + "`` will give the user the ``" + role.Name + "`` role!");
            }
            catch
            {
                await ReplyAsync("Sorry! Something went wrong! Make sure that I have permission to modify roles and that my role is higher than the selected one!");
            }
        }
Beispiel #3
0
        public async Task RoleWho(IRole role)
        {
            var users = (from user in await role.Guild.GetUsersAsync()
                         where user.RoleIds.Contains(role.Id)
                         let name = _users.Name(user)
                                    orderby name
                                    select name).ToArray();

            await DisplayItemList(users, () => "No one has this role", u => $"{u.Count} users have this role", (u, i) => $"{i + 1}. {u}");
        }
Beispiel #4
0
 public async Task TestRole(IRole role)
 {
     if (await _groups.IsUnlocked(role))
     {
         await TypingReplyAsync($"The role `{role.Name}` is **unlocked**");
     }
     else
     {
         await TypingReplyAsync($"The role `{role.Name}` is **locked**");
     }
 }
Beispiel #5
0
        public async Task LeaveRole(IRole role)
        {
            if (!await _groups.IsUnlocked(role))
            {
                await TypingReplyAsync("You cannot remove that role from yourself, it is not unlocked.");

                return;
            }

            if (Context.User is not IGuildUser gu)
            {
                await TypingReplyAsync("You need to do this within a guild channel");

                return;
            }

            await gu.RemoveRoleAsync(role);

            await TypingReplyAsync($"Removed role `{role.Name}` from `{gu.Nickname ?? gu.Username}`");
        }
Beispiel #6
0
        public async Task JoinRole(IRole role)
        {
            if (!await _groups.IsUnlocked(role))
            {
                await TypingReplyAsync("You cannot give yourself that role, it is not unlocked.");

                return;
            }

            if (Context.User is not IGuildUser gu)
            {
                await TypingReplyAsync("You need to do this within a guild channel");

                return;
            }

            await gu.AddRoleAsync(role);

            await TypingReplyAsync($"Granted role `{role.Name}` to `{gu.Nickname ?? gu.Username}`");
        }
Beispiel #7
0
 public async Task RoleId(IRole role)
 {
     await TypingReplyAsync($"ID for `{role.Name}` is `{role.Id}`");
 }
Beispiel #8
0
        public async Task LockRole(IRole role)
        {
            await _groups.Lock(role);

            await TypingReplyAsync($"Locked `{role.Name}`");
        }
Beispiel #9
0
        public async Task UnlockRole([NotNull] IRole role)
        {
            await _groups.Unlock(role);

            await TypingReplyAsync($"Unlocked `{role.Name}`");
        }