Beispiel #1
0
        public void AddRoleToUser(IEnumerable <Role> safeRoles, MessagesService messagesService, Contexts contexts, string commandRole)
        {
            var role = safeRoles.FirstOrDefault(x => x.Name == commandRole);

            if (role == null)
            {
                messagesService.SendResponse(x => x.RoleNotFoundOrIsNotSafe(contexts, commandRole), contexts);
                return;
            }
            if (contexts.User.Roles.Any(x => x.Name == role.Name))
            {
                messagesService.SendResponse(x => x.RoleIsInUserAlready(contexts, commandRole), contexts);
                return;
            }
            var serverRole = _usersRolesService.GetRoleByName(commandRole, contexts.Server);

            _usersService.AddRole(serverRole, contexts.User, contexts.Server).Wait();
            messagesService.SendResponse(x => x.RoleAddedToUser(contexts, commandRole), contexts);
        }
Beispiel #2
0
        private async Task AssignMuteRoleAsync(UserRole muteRole, UserContext userToMute, DiscordServerContext server)
        {
            await _usersService.AddRole(muteRole, userToMute, server);

            Log.Information("User {user} has been muted on server {server}", userToMute.ToString(), server.Name);
        }