public async Task <ActionResult <DSharpPlus.Entities.DiscordGuild> > GetAsync(string userId) { var userResult = await _discordBotService.GetUserByDiscordId(userId); if (userResult == null) { return(NotFound()); } var guildResult = await _discordBotService.GetGuild(userResult.Id); return((guildResult != null) ? Ok(guildResult.Roles) : (ActionResult)NotFound()); }
public async Task <ActionResult <DSharpPlus.Entities.DiscordUser> > UserAsync(string userId) { var result = await _discordBotService.GetUserByDiscordId(userId); return((result != null) ? Ok(result) : (ActionResult)NotFound()); }
private async Task <string> GetUser(string userId) { var resultJson = await _discordBotService.GetUserByDiscordId(userId); var discordUser = new DiscordUserDto(resultJson); return((discordUser != null) ? JsonSerializer.Serialize(discordUser) : "not found"); }
public async Task <ActionResult <DSharpPlus.Entities.DiscordGuild> > PutAsync(string userId, DiscordAppRole appRole) { var user = await _discordBotService.GetUserByDiscordId(userId); if (user == null) { return(NotFound()); } var guildMember = await _discordBotService.GetGuild(user.Id); if (guildMember == null) { return(NotFound()); } var projectsResult = _userService.GetProjectsByByDiscordId(userId); if (projectsResult.IsFailure) { return(NotFound()); } var guild = await _discordBotService.GetGuild(); if (guild == null) { return(NotFound()); } var roleName = $"{appRole.AppName} {appRole.SubRole}"; var role = guild.Roles.FirstOrDefault(x => x.Value.Name.Equals(roleName, StringComparison.OrdinalIgnoreCase)).Value; if (role == null) { role = await guild.CreateRoleAsync(roleName, null, new DiscordColor(appRole.Color), null, true); } return((guildMember != null) ? Ok(guildMember.Roles) : (ActionResult)NotFound()); }