Browse Source

Remove IUpdateable.Update from WebSocket entities

tags/1.0-rc
RogueException 9 years ago
parent
commit
57dfd93973
14 changed files with 28 additions and 70 deletions
  1. +2
    -2
      src/Discord.Net/Discord.Net.csproj
  2. +1
    -5
      src/Discord.Net/Rest/Entities/Guilds/Guild.cs
  3. +0
    -0
      src/Discord.Net/WebSocket/ChannelPermissionsCache.cs
  4. +2
    -7
      src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs
  5. +2
    -7
      src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
  6. +1
    -2
      src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs
  7. +1
    -2
      src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs
  8. +7
    -19
      src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs
  9. +1
    -3
      src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs
  10. +3
    -5
      src/Discord.Net/WebSocket/Entities/Message.cs
  11. +1
    -2
      src/Discord.Net/WebSocket/Entities/Role.cs
  12. +2
    -6
      src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs
  13. +5
    -10
      src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs
  14. +0
    -0
      src/Discord.Net/WebSocket/MessageCache.cs

+ 2
- 2
src/Discord.Net/Discord.Net.csproj View File

@@ -208,8 +208,8 @@
<Compile Include="Rest\Entities\Users\SelfUser.cs" />
<Compile Include="Rest\Entities\Users\User.cs" />
<Compile Include="TokenType.cs" />
<Compile Include="WebSocket\Caches\MessageCache.cs" />
<Compile Include="WebSocket\Caches\ChannelPermissionsCache.cs" />
<Compile Include="WebSocket\MessageCache.cs" />
<Compile Include="WebSocket\ChannelPermissionsCache.cs" />
<Compile Include="WebSocket\DiscordClient.cs" />
<Compile Include="WebSocket\Entities\Channels\DMChannel.cs" />
<Compile Include="WebSocket\Entities\Channels\GuildChannel.cs" />


+ 1
- 5
src/Discord.Net/Rest/Entities/Guilds/Guild.cs View File

@@ -140,15 +140,11 @@ namespace Discord.Rest
/// <inheritdoc />
public async Task ModifyChannels(IEnumerable<ModifyGuildChannelsParams> args)
{
if (args == null) throw new NullReferenceException(nameof(args));

await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task ModifyRoles(IEnumerable<ModifyGuildRolesParams> args)
{
if (args == null) throw new NullReferenceException(nameof(args));
{
var models = await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false);
Update(models);
}


src/Discord.Net/WebSocket/Caches/ChannelPermissionsCache.cs → src/Discord.Net/WebSocket/ChannelPermissionsCache.cs View File


+ 2
- 7
src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs View File

@@ -107,13 +107,6 @@ namespace Discord.WebSocket
await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false);
}

/// <inheritdoc />
public async Task Update()
{
var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false);
Update(model);
}

/// <inheritdoc />
public override string ToString() => $"@{Recipient} [DM]";
@@ -137,5 +130,7 @@ namespace Discord.WebSocket
=> await SendFile(stream, filename, text, isTTS).ConfigureAwait(false);
async Task IMessageChannel.TriggerTyping()
=> await TriggerTyping().ConfigureAwait(false);
Task IUpdateable.Update()
=> Task.CompletedTask;
}
}

+ 2
- 7
src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs View File

@@ -57,7 +57,6 @@ namespace Discord.WebSocket
var args = new ModifyGuildChannelParams();
func(args);
var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
Update(model);
}

/// <summary> Gets a user in this channel with the given id. </summary>
@@ -147,12 +146,6 @@ namespace Discord.WebSocket
{
await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task Update()
{
var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false);
Update(model);
}

IGuild IGuildChannel.Guild => Guild;
async Task<IGuildInvite> IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
@@ -167,5 +160,7 @@ namespace Discord.WebSocket
=> await GetUsers().ConfigureAwait(false);
async Task<IUser> IChannel.GetUser(ulong id)
=> await GetUser(id).ConfigureAwait(false);
Task IUpdateable.Update()
=> Task.CompletedTask;
}
}

+ 1
- 2
src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs View File

@@ -36,8 +36,7 @@ namespace Discord.WebSocket

var args = new ModifyTextChannelParams();
func(args);
var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
Update(model);
await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
}

protected override async Task<IEnumerable<GuildUser>> GetUsers()


+ 1
- 2
src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs View File

@@ -29,8 +29,7 @@ namespace Discord.WebSocket

var args = new ModifyVoiceChannelParams();
func(args);
var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
Update(model);
await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
}

protected override async Task<IEnumerable<GuildUser>> GetUsers()


+ 7
- 19
src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs View File

@@ -110,13 +110,7 @@ namespace Discord.WebSocket
role.Update(model);
}
}

/// <inheritdoc />
public async Task Update()
{
var response = await Discord.BaseClient.GetGuild(Id).ConfigureAwait(false);
Update(response);
}
/// <inheritdoc />
public async Task Modify(Action<ModifyGuildParams> func)
{
@@ -124,8 +118,7 @@ namespace Discord.WebSocket

var args = new ModifyGuildParams();
func(args);
var model = await Discord.BaseClient.ModifyGuild(Id, args).ConfigureAwait(false);
Update(model);
await Discord.BaseClient.ModifyGuild(Id, args).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task ModifyEmbed(Action<ModifyGuildEmbedParams> func)
@@ -134,24 +127,17 @@ namespace Discord.WebSocket

var args = new ModifyGuildEmbedParams();
func(args);
var model = await Discord.BaseClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false);

Update(model);
await Discord.BaseClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task ModifyChannels(IEnumerable<ModifyGuildChannelsParams> args)
{
if (args == null) throw new NullReferenceException(nameof(args));

await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task ModifyRoles(IEnumerable<ModifyGuildRolesParams> args)
{
if (args == null) throw new NullReferenceException(nameof(args));
var models = await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false);
Update(models);
{
await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task Leave()
@@ -370,5 +356,7 @@ namespace Discord.WebSocket
=> await GetCurrentUser().ConfigureAwait(false);
async Task<IEnumerable<IGuildUser>> IGuild.GetUsers()
=> await GetUsers().ConfigureAwait(false);
Task IUpdateable.Update()
=> Task.CompletedTask;
}
}

+ 1
- 3
src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs View File

@@ -67,9 +67,7 @@ namespace Discord.WebSocket

var args = new ModifyGuildIntegrationParams();
func(args);
var model = await Discord.BaseClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false);

Update(model);
await Discord.BaseClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false);
}
/// <summary> </summary>
public async Task Sync()


+ 3
- 5
src/Discord.Net/WebSocket/Entities/Message.cs View File

@@ -120,13 +120,11 @@ namespace Discord.WebSocket
var args = new ModifyMessageParams();
func(args);
var guildChannel = Channel as GuildChannel;

Model model;
if (guildChannel != null)
model = await Discord.BaseClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false);
await Discord.BaseClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false);
else
model = await Discord.BaseClient.ModifyMessage(Channel.Id, Id, args).ConfigureAwait(false);
Update(model);
await Discord.BaseClient.ModifyMessage(Channel.Id, Id, args).ConfigureAwait(false);
}

/// <inheritdoc />


+ 1
- 2
src/Discord.Net/WebSocket/Entities/Role.cs View File

@@ -58,8 +58,7 @@ namespace Discord.WebSocket

var args = new ModifyGuildRoleParams();
func(args);
var response = await Discord.BaseClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false);
Update(response);
await Discord.BaseClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false);
}
/// <summary> Deletes this message. </summary>
public async Task Delete()


+ 2
- 6
src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs View File

@@ -46,12 +46,6 @@ namespace Discord.WebSocket
_roles = roles.ToImmutable();
}

public async Task Update()
{
var model = await Discord.BaseClient.GetGuildMember(Guild.Id, Id).ConfigureAwait(false);
Update(model);
}

public bool HasRole(IRole role)
{
for (int i = 0; i < _roles.Length; i++)
@@ -113,5 +107,7 @@ namespace Discord.WebSocket

ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel)
=> GetPermissions(channel);
Task IUpdateable.Update()
=> Task.CompletedTask;
}
}

+ 5
- 10
src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs View File

@@ -26,14 +26,7 @@ namespace Discord.WebSocket
Email = model.Email;
IsVerified = model.IsVerified;
}

/// <inheritdoc />
public async Task Update()
{
var model = await Discord.BaseClient.GetCurrentUser().ConfigureAwait(false);
Update(model);
}

/// <inheritdoc />
public async Task Modify(Action<ModifyCurrentUserParams> func)
{
@@ -41,8 +34,10 @@ namespace Discord.WebSocket

var args = new ModifyCurrentUserParams();
func(args);
var model = await Discord.BaseClient.ModifyCurrentUser(args).ConfigureAwait(false);
Update(model);
await Discord.BaseClient.ModifyCurrentUser(args).ConfigureAwait(false);
}

Task IUpdateable.Update()
=> Task.CompletedTask;
}
}

src/Discord.Net/WebSocket/Caches/MessageCache.cs → src/Discord.Net/WebSocket/MessageCache.cs View File


Loading…
Cancel
Save