Browse Source

Now this should be ready to, I am the worst at git.

tags/1.0-rc
Sindre G. Langhus 8 years ago
parent
commit
25547407c8
3 changed files with 23 additions and 22 deletions
  1. +10
    -10
      src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs
  2. +5
    -5
      src/Discord.Net.WebSocket/DiscordShardedClient.cs
  3. +8
    -7
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 10
- 10
src/Discord.Net.WebSocket/DiscordShardedClient.Events.cs View File

@@ -33,36 +33,36 @@ namespace Discord.WebSocket
remove { _messageReceivedEvent.Remove(value); } remove { _messageReceivedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<SocketMessage, Task>> _messageReceivedEvent = new AsyncEvent<Func<SocketMessage, Task>>(); private readonly AsyncEvent<Func<SocketMessage, Task>> _messageReceivedEvent = new AsyncEvent<Func<SocketMessage, Task>>();
public event Func<ulong, Optional<SocketMessage>, Task> MessageDeleted
public event Func<Cacheable<SocketMessage, ulong>, ISocketMessageChannel, Task> MessageDeleted
{ {
add { _messageDeletedEvent.Add(value); } add { _messageDeletedEvent.Add(value); }
remove { _messageDeletedEvent.Remove(value); } remove { _messageDeletedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<ulong, Optional<SocketMessage>, Task>> _messageDeletedEvent = new AsyncEvent<Func<ulong, Optional<SocketMessage>, Task>>();
public event Func<Optional<SocketMessage>, SocketMessage, Task> MessageUpdated
private readonly AsyncEvent<Func<Cacheable<SocketMessage, ulong>, ISocketMessageChannel, Task>> _messageDeletedEvent = new AsyncEvent<Func<Cacheable<SocketMessage, ulong>, ISocketMessageChannel, Task>>();
public event Func<Cacheable<SocketMessage, ulong>, SocketMessage, ISocketMessageChannel, Task> MessageUpdated
{ {
add { _messageUpdatedEvent.Add(value); } add { _messageUpdatedEvent.Add(value); }
remove { _messageUpdatedEvent.Remove(value); } remove { _messageUpdatedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<Optional<SocketMessage>, SocketMessage, Task>> _messageUpdatedEvent = new AsyncEvent<Func<Optional<SocketMessage>, SocketMessage, Task>>();
public event Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task> ReactionAdded
private readonly AsyncEvent<Func<Cacheable<SocketMessage, ulong>, SocketMessage, ISocketMessageChannel, Task>> _messageUpdatedEvent = new AsyncEvent<Func<Cacheable<SocketMessage, ulong>, SocketMessage, ISocketMessageChannel, Task>>();
public event Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task> ReactionAdded
{ {
add { _reactionAddedEvent.Add(value); } add { _reactionAddedEvent.Add(value); }
remove { _reactionAddedEvent.Remove(value); } remove { _reactionAddedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task>> _reactionAddedEvent = new AsyncEvent<Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task>>();
public event Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task> ReactionRemoved
private readonly AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task>> _reactionAddedEvent = new AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task>>();
public event Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task> ReactionRemoved
{ {
add { _reactionRemovedEvent.Add(value); } add { _reactionRemovedEvent.Add(value); }
remove { _reactionRemovedEvent.Remove(value); } remove { _reactionRemovedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task>> _reactionRemovedEvent = new AsyncEvent<Func<ulong, Optional<SocketUserMessage>, SocketReaction, Task>>();
public event Func<ulong, Optional<SocketUserMessage>, Task> ReactionsCleared
private readonly AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task>> _reactionRemovedEvent = new AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task>>();
public event Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, Task> ReactionsCleared
{ {
add { _reactionsClearedEvent.Add(value); } add { _reactionsClearedEvent.Add(value); }
remove { _reactionsClearedEvent.Remove(value); } remove { _reactionsClearedEvent.Remove(value); }
} }
private readonly AsyncEvent<Func<ulong, Optional<SocketUserMessage>, Task>> _reactionsClearedEvent = new AsyncEvent<Func<ulong, Optional<SocketUserMessage>, Task>>();
private readonly AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, Task>> _reactionsClearedEvent = new AsyncEvent<Func<Cacheable<SocketUserMessage, ulong>, ISocketMessageChannel, Task>>();


//Roles //Roles
public event Func<SocketRole, Task> RoleCreated public event Func<SocketRole, Task> RoleCreated


+ 5
- 5
src/Discord.Net.WebSocket/DiscordShardedClient.cs View File

@@ -303,11 +303,11 @@ namespace Discord.WebSocket
client.ChannelUpdated += (oldChannel, newChannel) => _channelUpdatedEvent.InvokeAsync(oldChannel, newChannel); client.ChannelUpdated += (oldChannel, newChannel) => _channelUpdatedEvent.InvokeAsync(oldChannel, newChannel);


client.MessageReceived += (msg) => _messageReceivedEvent.InvokeAsync(msg); client.MessageReceived += (msg) => _messageReceivedEvent.InvokeAsync(msg);
client.MessageDeleted += (id, msg) => _messageDeletedEvent.InvokeAsync(id, msg);
client.MessageUpdated += (oldMsg, newMsg) => _messageUpdatedEvent.InvokeAsync(oldMsg, newMsg);
client.ReactionAdded += (id, msg, reaction) => _reactionAddedEvent.InvokeAsync(id, msg, reaction);
client.ReactionRemoved += (id, msg, reaction) => _reactionRemovedEvent.InvokeAsync(id, msg, reaction);
client.ReactionsCleared += (id, msg) => _reactionsClearedEvent.InvokeAsync(id, msg);
client.MessageDeleted += (cache, channel) => _messageDeletedEvent.InvokeAsync(cache, channel);
client.MessageUpdated += (oldMsg, newMsg, channel) => _messageUpdatedEvent.InvokeAsync(oldMsg, newMsg, channel);
client.ReactionAdded += (cache, channel, reaction) => _reactionAddedEvent.InvokeAsync(cache, channel, reaction);
client.ReactionRemoved += (cache, channel, reaction) => _reactionRemovedEvent.InvokeAsync(cache, channel, reaction);
client.ReactionsCleared += (cache, channel) => _reactionsClearedEvent.InvokeAsync(cache, channel);


client.RoleCreated += (role) => _roleCreatedEvent.InvokeAsync(role); client.RoleCreated += (role) => _roleCreatedEvent.InvokeAsync(role);
client.RoleDeleted += (role) => _roleDeletedEvent.InvokeAsync(role); client.RoleDeleted += (role) => _roleDeletedEvent.InvokeAsync(role);


+ 8
- 7
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -485,25 +485,25 @@ namespace Discord.WebSocket
} }
} }


public async Task SetStatus(UserStatus status)
public async Task SetStatusAsync(UserStatus status)
{ {
Status = status; Status = status;
if (status == UserStatus.AFK) if (status == UserStatus.AFK)
_statusSince = DateTimeOffset.UtcNow; _statusSince = DateTimeOffset.UtcNow;
else else
_statusSince = null; _statusSince = null;
await SendStatus().ConfigureAwait(false);
await SendStatusAsync().ConfigureAwait(false);
} }
public async Task SetGame(string name, string streamUrl = null, StreamType streamType = StreamType.NotStreaming)
public async Task SetGameAsync(string name, string streamUrl = null, StreamType streamType = StreamType.NotStreaming)
{ {
if (name != null) if (name != null)
Game = new Game(name, streamUrl, streamType); Game = new Game(name, streamUrl, streamType);
else else
Game = null; Game = null;
CurrentUser.Presence = new SocketPresence(Status, Game); CurrentUser.Presence = new SocketPresence(Status, Game);
await SendStatus().ConfigureAwait(false);
await SendStatusAsync().ConfigureAwait(false);
} }
private async Task SendStatus()
private async Task SendStatusAsync()
{ {
var game = Game; var game = Game;
var status = Status; var status = Status;
@@ -1205,8 +1205,9 @@ namespace Discord.WebSocket
return; return;
} }


SocketUser user = State.GetUser(data.User.Id) ??
(SocketUser) SocketSimpleUser.Create(this, State, data.User);
SocketUser user = State.GetUser(data.User.Id);
if (user == null)
user = SocketSimpleUser.Create(this, State, data.User);
await _userUnbannedEvent.InvokeAsync(user, guild).ConfigureAwait(false); await _userUnbannedEvent.InvokeAsync(user, guild).ConfigureAwait(false);
} }
else else


Loading…
Cancel
Save