@@ -708,7 +708,6 @@ namespace Discord | |||||
var server = GetServer(data.GuildId); | var server = GetServer(data.GuildId); | ||||
if (server != null) | if (server != null) | ||||
{ | { | ||||
server.AddBan(data.UserId); | |||||
if (Config.LogEvents) | if (Config.LogEvents) | ||||
Logger.Info($"User Banned: {server.Name}/{data.UserId}"); | Logger.Info($"User Banned: {server.Name}/{data.UserId}"); | ||||
OnUserBanned(server, data.UserId); | OnUserBanned(server, data.UserId); | ||||
@@ -721,12 +720,9 @@ namespace Discord | |||||
var server = GetServer(data.GuildId); | var server = GetServer(data.GuildId); | ||||
if (server != null) | if (server != null) | ||||
{ | { | ||||
if (server.RemoveBan(data.UserId)) | |||||
{ | |||||
if (Config.LogEvents) | |||||
Logger.Info($"User Unbanned: {server.Name}/{data.UserId}"); | |||||
OnUserUnbanned(server, data.UserId); | |||||
} | |||||
if (Config.LogEvents) | |||||
Logger.Info($"User Unbanned: {server.Name}/{data.UserId}"); | |||||
OnUserUnbanned(server, data.UserId); | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
@@ -739,38 +735,40 @@ namespace Discord | |||||
Channel channel = GetChannel(data.ChannelId); | Channel channel = GetChannel(data.ChannelId); | ||||
if (channel != null) | if (channel != null) | ||||
{ | { | ||||
Message msg = null; | |||||
bool isAuthor = data.Author.Id == CurrentUser.Id; | |||||
//ulong nonce = 0; | |||||
/*if (data.Author.Id == _privateUser.Id && Config.UseMessageQueue) | |||||
{ | |||||
if (data.Nonce != null && ulong.TryParse(data.Nonce, out nonce)) | |||||
msg = _messages[nonce]; | |||||
}*/ | |||||
if (msg == null) | |||||
{ | |||||
msg = channel.AddMessage(data.Id, data.Author.Id, data.Timestamp.Value); | |||||
//nonce = 0; | |||||
} | |||||
msg.Update(data); | |||||
var user = msg.User; | |||||
var user = channel.GetUser(data.Author.Id); | |||||
if (user != null) | if (user != null) | ||||
user.UpdateActivity();// data.Timestamp); | |||||
//Remapped queued message | |||||
/*if (nonce != 0) | |||||
{ | { | ||||
msg = _messages.Remap(nonce, data.Id); | |||||
msg.Id = data.Id; | |||||
RaiseMessageSent(msg); | |||||
}*/ | |||||
Message msg = null; | |||||
bool isAuthor = data.Author.Id == CurrentUser.Id; | |||||
//ulong nonce = 0; | |||||
/*if (data.Author.Id == _privateUser.Id && Config.UseMessageQueue) | |||||
{ | |||||
if (data.Nonce != null && ulong.TryParse(data.Nonce, out nonce)) | |||||
msg = _messages[nonce]; | |||||
}*/ | |||||
if (msg == null) | |||||
{ | |||||
msg = channel.AddMessage(data.Id, data.Author.Id, data.Timestamp.Value); | |||||
//nonce = 0; | |||||
} | |||||
//Remapped queued message | |||||
/*if (nonce != 0) | |||||
{ | |||||
msg = _messages.Remap(nonce, data.Id); | |||||
msg.Id = data.Id; | |||||
RaiseMessageSent(msg); | |||||
}*/ | |||||
msg.State = MessageState.Normal; | |||||
if (Config.LogEvents) | |||||
Logger.Verbose($"Message Received: {channel.Server?.Name ?? "[Private]"}/{channel.Name}"); | |||||
OnMessageReceived(msg); | |||||
msg.Update(data); | |||||
user.UpdateActivity(); | |||||
msg.State = MessageState.Normal; | |||||
if (Config.LogEvents) | |||||
Logger.Verbose($"Message Received: {channel.Server?.Name ?? "[Private]"}/{channel.Name}"); | |||||
OnMessageReceived(msg); | |||||
} | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
@@ -32,7 +32,6 @@ namespace Discord | |||||
private readonly ConcurrentDictionary<ulong, Role> _roles; | private readonly ConcurrentDictionary<ulong, Role> _roles; | ||||
private readonly ConcurrentDictionary<ulong, Member> _users; | private readonly ConcurrentDictionary<ulong, Member> _users; | ||||
private readonly ConcurrentDictionary<ulong, Channel> _channels; | private readonly ConcurrentDictionary<ulong, Channel> _channels; | ||||
private readonly ConcurrentDictionary<ulong, bool> _bans; | |||||
private ulong _ownerId; | private ulong _ownerId; | ||||
private ulong? _afkChannelId; | private ulong? _afkChannelId; | ||||
@@ -64,9 +63,7 @@ namespace Discord | |||||
public User CurrentUser => GetUser(Client.CurrentUser.Id); | public User CurrentUser => GetUser(Client.CurrentUser.Id); | ||||
/// <summary> Gets the URL to this user's current avatar. </summary> | /// <summary> Gets the URL to this user's current avatar. </summary> | ||||
public string IconUrl => GetIconUrl(Id, IconId); | public string IconUrl => GetIconUrl(Id, IconId); | ||||
/// <summary> Gets a collection of the ids of all users banned on this server. </summary> | |||||
public IEnumerable<ulong> BannedUserIds => _bans.Select(x => x.Key); | |||||
/// <summary> Gets a collection of all channels in this server. </summary> | /// <summary> Gets a collection of all channels in this server. </summary> | ||||
public IEnumerable<Channel> AllChannels => _channels.Select(x => x.Value); | public IEnumerable<Channel> AllChannels => _channels.Select(x => x.Value); | ||||
/// <summary> Gets a collection of text channels in this server. </summary> | /// <summary> Gets a collection of text channels in this server. </summary> | ||||
@@ -86,7 +83,6 @@ namespace Discord | |||||
_channels = new ConcurrentDictionary<ulong, Channel>(); | _channels = new ConcurrentDictionary<ulong, Channel>(); | ||||
_roles = new ConcurrentDictionary<ulong, Role>(); | _roles = new ConcurrentDictionary<ulong, Role>(); | ||||
_users = new ConcurrentDictionary<ulong, Member>(); | _users = new ConcurrentDictionary<ulong, Member>(); | ||||
_bans = new ConcurrentDictionary<ulong, bool>(); | |||||
DefaultChannel = AddChannel(id); | DefaultChannel = AddChannel(id); | ||||
EveryoneRole = AddRole(id); | EveryoneRole = AddRole(id); | ||||
} | } | ||||
@@ -176,14 +172,6 @@ namespace Discord | |||||
} | } | ||||
#region Bans | #region Bans | ||||
internal void AddBan(ulong banId) | |||||
=> _bans.TryAdd(banId, true); | |||||
internal bool RemoveBan(ulong banId) | |||||
{ | |||||
bool ignored; | |||||
return _bans.TryRemove(banId, out ignored); | |||||
} | |||||
public Task Ban(User user, int pruneDays = 0) | public Task Ban(User user, int pruneDays = 0) | ||||
{ | { | ||||
var request = new AddGuildBanRequest(user.Server.Id, user.Id) | var request = new AddGuildBanRequest(user.Server.Id, user.Id) | ||||