private async Task OnGuildRoleCreate(ulong guildId, DiscordRolePacket arg2) { try { DiscordGuildPacket guild = await _discordClient.GetGuildAsync(guildId); if (guild.Roles == null) { guild.Roles = new List <DiscordRolePacket>(); } int index = guild.Roles.FindIndex(x => x.Id == guildId); if (index == -1) { guild.Roles.Add(arg2); } else { guild.Roles[index] = arg2; } var cache = _cacheClient.Get; await cache.UpsertAsync($"discord:guild:{guildId}:role:{arg2.Id}", arg2); await cache.UpsertAsync($"discord:guild:{guildId}", guild); } catch (Exception e) { Log.Trace(e.ToString()); } }
public async Task <DiscordRolePacket> EditRoleAsync(ulong guildId, DiscordRolePacket role) { return((await RatelimitHelper.ProcessRateLimitedAsync( $"guilds:{guildId}", cache, async() => await RestClient.PutAsync <DiscordRolePacket>( $"/guilds/{guildId}/roles/{role.Id}", JsonConvert.SerializeObject(role) ) )).Data); }
/// <inheritdoc/> public async Task <DiscordRolePacket> EditRoleAsync( ulong guildId, DiscordRolePacket role) { var response = await httpClient.PutAsync( DiscordApiRoutes.GuildRole(guildId, role.Id), JsonSerializer.Serialize(role, options)) .ConfigureAwait(false); HandleErrors(response, options); return(JsonSerializer.Deserialize <DiscordRolePacket>(response.Body, options)); }
public async ValueTask <DiscordRolePacket> EditRoleAsync( ulong guildId, DiscordRolePacket role) { var response = await RestClient.PutJsonAsync( DiscordApiRoutes.GuildRole(guildId, role.Id), role) .ConfigureAwait(false); HandleErrors(response); return(JsonHelper.Deserialize <DiscordRolePacket>(response.Body)); }
private async Task OnGuildRoleCreate(ulong guildId, DiscordRolePacket arg2) { DiscordGuildPacket guild = await _discordClient.GetGuildAsync(guildId); if (guild.Roles == null) { guild.Roles = new List <DiscordRolePacket>(); } int index = guild.Roles.FindIndex(x => x.Id == guildId); if (index == -1) { guild.Roles.Add(arg2); } else { guild.Roles[index] = arg2; } await _cacheClient.AddAsync($"discord:guild:{guildId}:role:{arg2.Id}", arg2); await _cacheClient.AddAsync($"discord:guild:{guildId}", guild); }
public async Task <IDiscordRole> EditRoleAsync(ulong guildId, DiscordRolePacket role) => new DiscordRole(await _apiClient.EditRoleAsync(guildId, role), this);
public virtual async Task <IDiscordRole> EditRoleAsync(ulong guildId, DiscordRolePacket role) { return(new DiscordRole(await ApiClient.EditRoleAsync(guildId, role), this)); }
public DiscordRole(DiscordRolePacket packet, DiscordClient client) { _packet = packet; _client = client; }
public DiscordRole(DiscordRolePacket packet, IDiscordClient client) { this.packet = packet; this.client = client; }
private static bool ValidateCache(DiscordRolePacket p) => !string.IsNullOrEmpty(p.Name);