|
@@ -222,21 +222,31 @@ namespace Discord |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Members |
|
|
//Members |
|
|
public Task EditMember(Member member, bool? mute = null, bool? deaf = null, string[] roles = null) |
|
|
|
|
|
|
|
|
public Task EditMember(Member member, bool? mute = null, bool? deaf = null, IEnumerable<object> roles = null) |
|
|
=> EditMember(member?.ServerId, member?.UserId, mute, deaf, roles); |
|
|
=> EditMember(member?.ServerId, member?.UserId, mute, deaf, roles); |
|
|
public Task EditMember(Server server, User user, bool? mute = null, bool? deaf = null, string[] roles = null) |
|
|
|
|
|
|
|
|
public Task EditMember(Server server, User user, bool? mute = null, bool? deaf = null, IEnumerable<object> roles = null) |
|
|
=> EditMember(server?.Id, user?.Id, mute, deaf, roles); |
|
|
=> EditMember(server?.Id, user?.Id, mute, deaf, roles); |
|
|
public Task EditMember(Server server, string userId, bool? mute = null, bool? deaf = null, string[] roles = null) |
|
|
|
|
|
|
|
|
public Task EditMember(Server server, string userId, bool? mute = null, bool? deaf = null, IEnumerable<string> roles = null) |
|
|
=> EditMember(server?.Id, userId, mute, deaf, roles); |
|
|
=> EditMember(server?.Id, userId, mute, deaf, roles); |
|
|
public Task EditMember(string serverId, User user, bool? mute = null, bool? deaf = null, string[] roles = null) |
|
|
|
|
|
|
|
|
public Task EditMember(string serverId, User user, bool? mute = null, bool? deaf = null, IEnumerable<object> roles = null) |
|
|
=> EditMember(serverId, user?.Id, mute, deaf, roles); |
|
|
=> EditMember(serverId, user?.Id, mute, deaf, roles); |
|
|
public Task EditMember(string serverId, string userId, bool? mute = null, bool? deaf = null, string[] roles = null) |
|
|
|
|
|
|
|
|
public Task EditMember(string serverId, string userId, bool? mute = null, bool? deaf = null, IEnumerable<object> roles = null) |
|
|
{ |
|
|
{ |
|
|
CheckReady(); |
|
|
CheckReady(); |
|
|
if (serverId == null) throw new NullReferenceException(nameof(serverId)); |
|
|
if (serverId == null) throw new NullReferenceException(nameof(serverId)); |
|
|
if (userId == null) throw new NullReferenceException(nameof(userId)); |
|
|
if (userId == null) throw new NullReferenceException(nameof(userId)); |
|
|
|
|
|
|
|
|
return _api.EditMember(serverId, userId, mute, deaf, roles); |
|
|
|
|
|
|
|
|
IEnumerable<string> newRoles = roles?.Select(x => |
|
|
|
|
|
{ |
|
|
|
|
|
if (x is string) |
|
|
|
|
|
return x as string; |
|
|
|
|
|
else if (x is Role) |
|
|
|
|
|
return (x as Role).Id; |
|
|
|
|
|
else |
|
|
|
|
|
throw new ArgumentException("Roles must be a collection of strings or roles.", nameof(roles)); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return _api.EditMember(serverId, userId, mute, deaf, newRoles); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Messages |
|
|
//Messages |
|
@@ -263,7 +273,7 @@ namespace Discord |
|
|
CheckReady(); |
|
|
CheckReady(); |
|
|
if (channel == null) throw new ArgumentNullException(nameof(channel)); |
|
|
if (channel == null) throw new ArgumentNullException(nameof(channel)); |
|
|
if (text == null) throw new ArgumentNullException(nameof(text)); |
|
|
if (text == null) throw new ArgumentNullException(nameof(text)); |
|
|
if (mentions == null) throw new ArgumentNullException(nameof(mentions)); |
|
|
|
|
|
|
|
|
mentions = mentions ?? new string[0]; |
|
|
|
|
|
|
|
|
int blockCount = (int)Math.Ceiling(text.Length / (double)MaxMessageSize); |
|
|
int blockCount = (int)Math.Ceiling(text.Length / (double)MaxMessageSize); |
|
|
Message[] result = new Message[blockCount]; |
|
|
Message[] result = new Message[blockCount]; |
|
@@ -330,19 +340,20 @@ namespace Discord |
|
|
|
|
|
|
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
public Task EditMessage(Message message, string text = null, string[] mentions = null) |
|
|
|
|
|
|
|
|
public Task EditMessage(Message message, string text = null, params string[] mentions) |
|
|
=> EditMessage(message?.ChannelId, message?.Id, text, mentions); |
|
|
=> EditMessage(message?.ChannelId, message?.Id, text, mentions); |
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
public Task EditMessage(Channel channel, string messageId, string text = null, string[] mentions = null) |
|
|
|
|
|
|
|
|
public Task EditMessage(Channel channel, string messageId, string text = null, params string[] mentions) |
|
|
=> EditMessage(channel?.Id, messageId, text, mentions); |
|
|
=> EditMessage(channel?.Id, messageId, text, mentions); |
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <summary> Edits the provided message, changing only non-null attributes. </summary> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
/// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks> |
|
|
public async Task EditMessage(string channelId, string messageId, string text = null, string[] mentions = null) |
|
|
|
|
|
|
|
|
public async Task EditMessage(string channelId, string messageId, string text = null, params string[] mentions) |
|
|
{ |
|
|
{ |
|
|
CheckReady(); |
|
|
CheckReady(); |
|
|
if (channelId == null) throw new ArgumentNullException(nameof(channelId)); |
|
|
if (channelId == null) throw new ArgumentNullException(nameof(channelId)); |
|
|
if (messageId == null) throw new ArgumentNullException(nameof(messageId)); |
|
|
if (messageId == null) throw new ArgumentNullException(nameof(messageId)); |
|
|
|
|
|
mentions = mentions ?? new string[0]; |
|
|
|
|
|
|
|
|
if (text != null && text.Length > MaxMessageSize) |
|
|
if (text != null && text.Length > MaxMessageSize) |
|
|
text = text.Substring(0, MaxMessageSize); |
|
|
text = text.Substring(0, MaxMessageSize); |
|
|