diff --git a/Discord.Net.targets b/Discord.Net.targets
index 958b2053f..079ec7749 100644
--- a/Discord.Net.targets
+++ b/Discord.Net.targets
@@ -16,13 +16,7 @@
$(VersionSuffix)-$(BuildNumber)
build-$(BuildNumber)
-
-
- $(DefineConstants);FILESYSTEM;DEFAULTUDPCLIENT;DEFAULTWEBSOCKET
-
-
- $(DefineConstants);FORMATSTR;UNIXTIME;MSTRYBUFFER;UDPDISPOSE
-
+
$(NoWarn);CS1573;CS1591
true
diff --git a/samples/02_commands_framework/02_commands_framework.csproj b/samples/02_commands_framework/02_commands_framework.csproj
index 77fdc65e1..f479ee0b0 100644
--- a/samples/02_commands_framework/02_commands_framework.csproj
+++ b/samples/02_commands_framework/02_commands_framework.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/Discord.Net.Analyzers/Discord.Net.Analyzers.csproj b/src/Discord.Net.Analyzers/Discord.Net.Analyzers.csproj
index 8ab398ff5..5da3d506d 100644
--- a/src/Discord.Net.Analyzers/Discord.Net.Analyzers.csproj
+++ b/src/Discord.Net.Analyzers/Discord.Net.Analyzers.csproj
@@ -7,7 +7,7 @@
netstandard1.3
-
+
diff --git a/src/Discord.Net.Commands/CommandParser.cs b/src/Discord.Net.Commands/CommandParser.cs
index 02011bd9f..49df92a31 100644
--- a/src/Discord.Net.Commands/CommandParser.cs
+++ b/src/Discord.Net.Commands/CommandParser.cs
@@ -1,4 +1,5 @@
-using System;
+using System;
+using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using System.Threading.Tasks;
@@ -13,8 +14,7 @@ namespace Discord.Commands
Parameter,
QuotedParameter
}
-
- public static async Task ParseArgsAsync(CommandInfo command, ICommandContext context, IServiceProvider services, string input, int startPos)
+ public static async Task ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos, IReadOnlyDictionary aliasMap)
{
ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -24,7 +24,27 @@ namespace Discord.Commands
var argList = ImmutableArray.CreateBuilder();
var paramList = ImmutableArray.CreateBuilder();
bool isEscaping = false;
- char c;
+ char c, matchQuote = '\0';
+
+ // local helper functions
+ bool IsOpenQuote(IReadOnlyDictionary dict, char ch)
+ {
+ // return if the key is contained in the dictionary if it is populated
+ if (dict.Count != 0)
+ return dict.ContainsKey(ch);
+ // or otherwise if it is the default double quote
+ return c == '\"';
+ }
+
+ char GetMatch(IReadOnlyDictionary dict, char ch)
+ {
+ // get the corresponding value for the key, if it exists
+ // and if the dictionary is populated
+ if (dict.Count != 0 && dict.TryGetValue(c, out var value))
+ return value;
+ // or get the default pair of the default double quote
+ return '\"';
+ }
for (int curPos = startPos; curPos <= endPos; curPos++)
{
@@ -74,9 +94,11 @@ namespace Discord.Commands
argBuilder.Append(c);
continue;
}
- if (c == '\"')
+
+ if (IsOpenQuote(aliasMap, c))
{
curPart = ParserPart.QuotedParameter;
+ matchQuote = GetMatch(aliasMap, c);
continue;
}
curPart = ParserPart.Parameter;
@@ -97,7 +119,7 @@ namespace Discord.Commands
}
else if (curPart == ParserPart.QuotedParameter)
{
- if (c == '\"')
+ if (c == matchQuote)
{
argString = argBuilder.ToString(); //Remove quotes
lastArgEndPos = curPos + 1;
diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs
index 24db6e9b5..0c23f79d0 100644
--- a/src/Discord.Net.Commands/CommandService.cs
+++ b/src/Discord.Net.Commands/CommandService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -38,6 +38,7 @@ namespace Discord.Commands
internal readonly RunMode _defaultRunMode;
internal readonly Logger _cmdLogger;
internal readonly LogManager _logManager;
+ internal readonly IReadOnlyDictionary _quotationMarkAliasMap;
///
/// Represents all modules loaded within .
@@ -73,6 +74,7 @@ namespace Discord.Commands
_ignoreExtraArgs = config.IgnoreExtraArgs;
_separatorChar = config.SeparatorChar;
_defaultRunMode = config.DefaultRunMode;
+ _quotationMarkAliasMap = (config.QuotationMarkAliasMap ?? new Dictionary()).ToImmutableDictionary();
if (_defaultRunMode == RunMode.Default)
throw new InvalidOperationException("The default run mode cannot be set to Default.");
@@ -93,6 +95,10 @@ namespace Discord.Commands
_defaultTypeReaders[typeof(Nullable<>).MakeGenericType(type)] = NullableTypeReader.Create(type, _defaultTypeReaders[type]);
}
+ var tsreader = new TimeSpanTypeReader();
+ _defaultTypeReaders[typeof(TimeSpan)] = tsreader;
+ _defaultTypeReaders[typeof(TimeSpan?)] = NullableTypeReader.Create(typeof(TimeSpan), tsreader);
+
_defaultTypeReaders[typeof(string)] =
new PrimitiveTypeReader((string x, out string y) => { y = x; return true; }, 0);
@@ -447,7 +453,6 @@ namespace Discord.Commands
public async Task ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
{
services = services ?? EmptyServiceProvider.Instance;
-
var searchResult = Search(context, input);
if (!searchResult.IsSuccess)
return searchResult;
diff --git a/src/Discord.Net.Commands/CommandServiceConfig.cs b/src/Discord.Net.Commands/CommandServiceConfig.cs
index f06289a8d..cd4ddbf94 100644
--- a/src/Discord.Net.Commands/CommandServiceConfig.cs
+++ b/src/Discord.Net.Commands/CommandServiceConfig.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
namespace Discord.Commands
{
@@ -33,9 +34,11 @@ namespace Discord.Commands
///
public bool ThrowOnError { get; set; } = true;
- ///
- /// Gets or sets whether extra parameters should be ignored.
- ///
+ /// Collection of aliases that can wrap strings for command parsing.
+ /// represents the opening quotation mark and the value is the corresponding closing mark.
+ public Dictionary QuotationMarkAliasMap { get; set; } = QuotationAliasUtils.GetDefaultAliasMap;
+
+ /// Determines whether extra parameters should be ignored.
public bool IgnoreExtraArgs { get; set; } = false;
}
}
diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.csproj b/src/Discord.Net.Commands/Discord.Net.Commands.csproj
index 9694dd5fc..a754486dd 100644
--- a/src/Discord.Net.Commands/Discord.Net.Commands.csproj
+++ b/src/Discord.Net.Commands/Discord.Net.Commands.csproj
@@ -1,15 +1,19 @@
-
+
Discord.Net.Commands
Discord.Commands
A Discord.Net extension adding support for bot commands.
- netstandard1.1;netstandard1.3
+ net46;netstandard1.3;netstandard2.0
+ netstandard1.3;netstandard2.0
-
+
+
+
+
\ No newline at end of file
diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs
index 3f4429bad..0f0572be7 100644
--- a/src/Discord.Net.Commands/Info/CommandInfo.cs
+++ b/src/Discord.Net.Commands/Info/CommandInfo.cs
@@ -1,4 +1,4 @@
-using Discord.Commands.Builders;
+using Discord.Commands.Builders;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -172,7 +172,8 @@ namespace Discord.Commands
return ParseResult.FromError(preconditionResult);
string input = searchResult.Text.Substring(startIndex);
- return await CommandParser.ParseArgsAsync(this, context, services, input, 0).ConfigureAwait(false);
+
+ return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0, _commandService._quotationMarkAliasMap).ConfigureAwait(false);
}
public Task ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)
diff --git a/src/Discord.Net.Commands/PrimitiveParsers.cs b/src/Discord.Net.Commands/PrimitiveParsers.cs
index 6a54ba402..bf0622c28 100644
--- a/src/Discord.Net.Commands/PrimitiveParsers.cs
+++ b/src/Discord.Net.Commands/PrimitiveParsers.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -29,7 +29,7 @@ namespace Discord.Commands
parserBuilder[typeof(decimal)] = (TryParseDelegate)decimal.TryParse;
parserBuilder[typeof(DateTime)] = (TryParseDelegate)DateTime.TryParse;
parserBuilder[typeof(DateTimeOffset)] = (TryParseDelegate)DateTimeOffset.TryParse;
- parserBuilder[typeof(TimeSpan)] = (TryParseDelegate)TimeSpan.TryParse;
+ //parserBuilder[typeof(TimeSpan)] = (TryParseDelegate)TimeSpan.TryParse;
parserBuilder[typeof(char)] = (TryParseDelegate)char.TryParse;
return parserBuilder.ToImmutable();
}
diff --git a/src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs b/src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs
new file mode 100644
index 000000000..31ab9d821
--- /dev/null
+++ b/src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Globalization;
+using System.Threading.Tasks;
+
+namespace Discord.Commands
+{
+ internal class TimeSpanTypeReader : TypeReader
+ {
+ private static readonly string[] _formats = new[]
+ {
+ "%d'd'%h'h'%m'm'%s's'", //4d3h2m1s
+ "%d'd'%h'h'%m'm'", //4d3h2m
+ "%d'd'%h'h'%s's'", //4d3h 1s
+ "%d'd'%h'h'", //4d3h
+ "%d'd'%m'm'%s's'", //4d 2m1s
+ "%d'd'%m'm'", //4d 2m
+ "%d'd'%s's'", //4d 1s
+ "%d'd'", //4d
+ "%h'h'%m'm'%s's'", // 3h2m1s
+ "%h'h'%m'm'", // 3h2m
+ "%h'h'%s's'", // 3h 1s
+ "%h'h'", // 3h
+ "%m'm'%s's'", // 2m1s
+ "%m'm'", // 2m
+ "%s's'", // 1s
+ };
+
+ public override Task ReadAsync(ICommandContext context, string input, IServiceProvider services)
+ {
+ return (TimeSpan.TryParseExact(input.ToLowerInvariant(), _formats, CultureInfo.InvariantCulture, out var timeSpan))
+ ? Task.FromResult(TypeReaderResult.FromSuccess(timeSpan))
+ : Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Failed to parse TimeSpan"));
+ }
+ }
+}
diff --git a/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs b/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs
new file mode 100644
index 000000000..15a08b9b3
--- /dev/null
+++ b/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Globalization;
+
+namespace Discord.Commands
+{
+ ///
+ /// Utility methods for generating matching pairs of unicode quotation marks for CommandServiceConfig
+ ///
+ internal static class QuotationAliasUtils
+ {
+ ///
+ /// Generates an IEnumerable of characters representing open-close pairs of
+ /// quotation punctuation.
+ ///
+ internal static Dictionary GetDefaultAliasMap
+ {
+ get
+ {
+ // Output of a gist provided by https://gist.github.com/ufcpp
+ // https://gist.github.com/ufcpp/5b2cf9a9bf7d0b8743714a0b88f7edc5
+ // This was not used for the implementation because of incompatibility with netstandard1.1
+ return new Dictionary {
+ {'\"', '\"' },
+ {'«', '»' },
+ {'‘', '’' },
+ {'“', '”' },
+ {'„', '‟' },
+ {'‹', '›' },
+ {'‚', '‛' },
+ {'《', '》' },
+ {'〈', '〉' },
+ {'「', '」' },
+ {'『', '』' },
+ {'〝', '〞' },
+ {'﹁', '﹂' },
+ {'﹃', '﹄' },
+ {'"', '"' },
+ {''', ''' },
+ {'「', '」' },
+ {'(', ')' },
+ {'༺', '༻' },
+ {'༼', '༽' },
+ {'᚛', '᚜' },
+ {'⁅', '⁆' },
+ {'⌈', '⌉' },
+ {'⌊', '⌋' },
+ {'❨', '❩' },
+ {'❪', '❫' },
+ {'❬', '❭' },
+ {'❮', '❯' },
+ {'❰', '❱' },
+ {'❲', '❳' },
+ {'❴', '❵' },
+ {'⟅', '⟆' },
+ {'⟦', '⟧' },
+ {'⟨', '⟩' },
+ {'⟪', '⟫' },
+ {'⟬', '⟭' },
+ {'⟮', '⟯' },
+ {'⦃', '⦄' },
+ {'⦅', '⦆' },
+ {'⦇', '⦈' },
+ {'⦉', '⦊' },
+ {'⦋', '⦌' },
+ {'⦍', '⦎' },
+ {'⦏', '⦐' },
+ {'⦑', '⦒' },
+ {'⦓', '⦔' },
+ {'⦕', '⦖' },
+ {'⦗', '⦘' },
+ {'⧘', '⧙' },
+ {'⧚', '⧛' },
+ {'⧼', '⧽' },
+ {'⸂', '⸃' },
+ {'⸄', '⸅' },
+ {'⸉', '⸊' },
+ {'⸌', '⸍' },
+ {'⸜', '⸝' },
+ {'⸠', '⸡' },
+ {'⸢', '⸣' },
+ {'⸤', '⸥' },
+ {'⸦', '⸧' },
+ {'⸨', '⸩' },
+ {'【', '】'},
+ {'〔', '〕' },
+ {'〖', '〗' },
+ {'〘', '〙' },
+ {'〚', '〛' }
+ };
+ }
+ }
+ }
+}
diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj
index 7565fa178..6a58367e6 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.csproj
+++ b/src/Discord.Net.Core/Discord.Net.Core.csproj
@@ -1,15 +1,15 @@
-
+
Discord.Net.Core
Discord
The core components for the Discord.Net library.
- net45;netstandard1.1;netstandard1.3
- netstandard1.1;netstandard1.3
+ net46;netstandard1.3;netstandard2.0
+ netstandard1.3;netstandard2.0
-
-
+
+
diff --git a/src/Discord.Net.Core/DiscordConfig.cs b/src/Discord.Net.Core/DiscordConfig.cs
index 0e46f2960..c65810d4e 100644
--- a/src/Discord.Net.Core/DiscordConfig.cs
+++ b/src/Discord.Net.Core/DiscordConfig.cs
@@ -93,6 +93,7 @@ namespace Discord
/// The maximum number of guilds that can be gotten per-batch.
///
public const int MaxGuildsPerBatch = 100;
+ public const int MaxUserReactionsPerBatch = 100;
public const int MaxAuditLogEntriesPerBatch = 100;
///
diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
index 837e90604..803e07ff6 100644
--- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
@@ -20,8 +20,7 @@ namespace Discord
///
/// An awaitable Task containing the message sent to the channel.
///
- Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#if FILESYSTEM
+ Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
///
/// Sends a file to this message channel with an optional caption.
///
@@ -39,7 +38,6 @@ namespace Discord
/// An awaitable Task containing the message sent to the channel.
///
Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#endif
///
/// Sends a file to this message channel with an optional caption.
///
@@ -121,6 +119,11 @@ namespace Discord
///
Task> GetPinnedMessagesAsync(RequestOptions options = null);
+ /// Deletes a message based on the message ID in this channel.
+ Task DeleteMessageAsync(ulong messageId, RequestOptions options = null);
+ /// Deletes a message based on the provided message in this channel.
+ Task DeleteMessageAsync(IMessage message, RequestOptions options = null);
+
///
/// Broadcasts the "user is typing" message to all users in this channel, lasting 10 seconds.
///
diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index 581ca551e..e38c01c6d 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -414,7 +414,7 @@ namespace Discord
///
/// An awaitable containing the newly created text channel.
///
- Task CreateTextChannelAsync(string name, RequestOptions options = null);
+ Task CreateTextChannelAsync(string name, Action func = null, RequestOptions options = null);
///
/// Creates a new voice channel.
///
@@ -423,13 +423,11 @@ namespace Discord
///
/// An awaitable containing the newly created voice channel.
///
- Task CreateVoiceChannelAsync(string name, RequestOptions options = null);
+ Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null);
///
/// Creates a new channel category.
///
/// The new name for the category.
- /// The options to be used when sending the request.
- ///
/// An awaitable containing the newly created category channel.
///
Task CreateCategoryAsync(string name, RequestOptions options = null);
diff --git a/src/Discord.Net.Core/Entities/Image.cs b/src/Discord.Net.Core/Entities/Image.cs
index 5453027ac..2fc0e50b9 100644
--- a/src/Discord.Net.Core/Entities/Image.cs
+++ b/src/Discord.Net.Core/Entities/Image.cs
@@ -1,4 +1,3 @@
-using System;
using System.IO;
namespace Discord
{
@@ -22,7 +21,7 @@ namespace Discord
{
Stream = stream;
}
-#if FILESYSTEM
+
///
/// Create the image from a file path.
///
@@ -55,6 +54,6 @@ namespace Discord
{
Stream = File.OpenRead(path);
}
-#endif
+
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
index 18ef93266..bad4e36c7 100644
--- a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
@@ -42,7 +42,7 @@ namespace Discord
///
/// Gets all users that reacted to a message with a given emote.
///
- Task> GetReactionUsersAsync(IEmote emoji, int limit = 100, ulong? afterUserId = null, RequestOptions options = null);
+ IAsyncEnumerable> GetReactionUsersAsync(IEmote emoji, int limit, RequestOptions options = null);
///
/// Transforms this message's text into a human-readable form by resolving its tags.
diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs
index 663c7fc6c..f2724778f 100644
--- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs
+++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs
@@ -41,13 +41,9 @@ namespace Discord
/// Allows for viewing of audit logs.
///
ViewAuditLog = 0x00_00_00_80,
- ///
- /// Allows for reading of message.
- ///
- ReadMessages = 0x00_00_04_00,
- ///
- /// Allows for sending messages in a channel.
- ///
+ [Obsolete("Use ViewChannel instead.")]
+ ReadMessages = ViewChannel,
+ ViewChannel = 0x00_00_04_00,
SendMessages = 0x00_00_08_00,
///
/// Allows for sending of text-to-speech messages.
diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
index 9a0cb2919..c77883832 100644
--- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
+++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -34,9 +35,12 @@ namespace Discord
/// If true, a user may view the audit log.
public bool ViewAuditLog => Permissions.GetValue(RawValue, GuildPermission.ViewAuditLog);
- /// If true, a user may join channels.
- public bool ReadMessages => Permissions.GetValue(RawValue, GuildPermission.ReadMessages);
- /// If true, a user may send messages.
+ /// If True, a user may join channels.
+ [Obsolete("Use ViewChannel instead.")]
+ public bool ReadMessages => ViewChannel;
+ /// If True, a user may view channels.
+ public bool ViewChannel => Permissions.GetValue(RawValue, GuildPermission.ViewChannel);
+ /// If True, a user may send messages.
public bool SendMessages => Permissions.GetValue(RawValue, GuildPermission.SendMessages);
/// If true, a user may send text-to-speech messages.
public bool SendTTSMessages => Permissions.GetValue(RawValue, GuildPermission.SendTTSMessages);
@@ -83,7 +87,7 @@ namespace Discord
private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, bool? kickMembers = null,
bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null,
bool? addReactions = null, bool? viewAuditLog = null,
- bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
+ bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null,
@@ -99,7 +103,7 @@ namespace Discord
Permissions.SetValue(ref value, manageGuild, GuildPermission.ManageGuild);
Permissions.SetValue(ref value, addReactions, GuildPermission.AddReactions);
Permissions.SetValue(ref value, viewAuditLog, GuildPermission.ViewAuditLog);
- Permissions.SetValue(ref value, readMessages, GuildPermission.ReadMessages);
+ Permissions.SetValue(ref value, viewChannel, GuildPermission.ViewChannel);
Permissions.SetValue(ref value, sendMessages, GuildPermission.SendMessages);
Permissions.SetValue(ref value, sendTTSMessages, GuildPermission.SendTTSMessages);
Permissions.SetValue(ref value, manageMessages, GuildPermission.ManageMessages);
@@ -127,14 +131,14 @@ namespace Discord
public GuildPermissions(bool createInstantInvite = false, bool kickMembers = false,
bool banMembers = false, bool administrator = false, bool manageChannels = false, bool manageGuild = false,
bool addReactions = false, bool viewAuditLog = false,
- bool readMessages = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false,
+ bool viewChannel = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false,
bool embedLinks = false, bool attachFiles = false, bool readMessageHistory = false, bool mentionEveryone = false,
bool useExternalEmojis = false, bool connect = false, bool speak = false, bool muteMembers = false, bool deafenMembers = false,
bool moveMembers = false, bool useVoiceActivation = false, bool? changeNickname = false, bool? manageNicknames = false,
bool manageRoles = false, bool manageWebhooks = false, bool manageEmojis = false)
: this(0, createInstantInvite: createInstantInvite, manageRoles: manageRoles, kickMembers: kickMembers, banMembers: banMembers,
administrator: administrator, manageChannels: manageChannels, manageGuild: manageGuild, addReactions: addReactions,
- viewAuditLog: viewAuditLog, readMessages: readMessages, sendMessages: sendMessages, sendTTSMessages: sendTTSMessages,
+ viewAuditLog: viewAuditLog, viewChannel: viewChannel, sendMessages: sendMessages, sendTTSMessages: sendTTSMessages,
manageMessages: manageMessages, embedLinks: embedLinks, attachFiles: attachFiles, readMessageHistory: readMessageHistory,
mentionEveryone: mentionEveryone, useExternalEmojis: useExternalEmojis, connect: connect, speak: speak, muteMembers: muteMembers,
deafenMembers: deafenMembers, moveMembers: moveMembers, useVoiceActivation: useVoiceActivation, changeNickname: changeNickname,
@@ -145,13 +149,13 @@ namespace Discord
public GuildPermissions Modify(bool? createInstantInvite = null, bool? kickMembers = null,
bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null,
bool? addReactions = null, bool? viewAuditLog = null,
- bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
+ bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null,
bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojis = null)
=> new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions,
- viewAuditLog, readMessages, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
+ viewAuditLog, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers,
useVoiceActivation, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojis);
diff --git a/src/Discord.Net.Core/Entities/Roles/Color.cs b/src/Discord.Net.Core/Entities/Roles/Color.cs
index fa7624a57..f24ac883e 100644
--- a/src/Discord.Net.Core/Entities/Roles/Color.cs
+++ b/src/Discord.Net.Core/Entities/Roles/Color.cs
@@ -1,5 +1,8 @@
using System;
using System.Diagnostics;
+#if NETSTANDARD2_0 || NET45
+using StandardColor = System.Drawing.Color;
+#endif
namespace Discord
{
@@ -125,6 +128,13 @@ namespace Discord
(uint)(b * 255.0f);
}
+#if NETSTANDARD2_0 || NET45
+ public static implicit operator StandardColor(Color color) =>
+ StandardColor.FromArgb((int)color.RawValue);
+ public static explicit operator Color(StandardColor color) =>
+ new Color((uint)color.ToArgb() << 8 >> 8);
+#endif
+
///
/// Gets the hexadecimal representation of the color (e.g. #000ccc).
///
diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs
index 41e84c3cb..7759c8ea3 100644
--- a/src/Discord.Net.Core/Extensions/UserExtensions.cs
+++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs
@@ -18,7 +18,7 @@ namespace Discord
/// An awaitable Task containing the message sent to the channel.
///
public static async Task SendMessageAsync(this IUser user,
- string text,
+ string text = null,
bool isTTS = false,
Embed embed = null,
RequestOptions options = null)
@@ -55,7 +55,6 @@ namespace Discord
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
}
-#if FILESYSTEM
///
/// Sends a file via DM with an optional caption.
///
@@ -81,7 +80,7 @@ namespace Discord
{
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
}
-#endif
+
///
/// Bans the provided user from the guild and optionally prunes their recent messages.
///
diff --git a/src/Discord.Net.Core/Logging/LogManager.cs b/src/Discord.Net.Core/Logging/LogManager.cs
index 35727c33d..a99c45b39 100644
--- a/src/Discord.Net.Core/Logging/LogManager.cs
+++ b/src/Discord.Net.Core/Logging/LogManager.cs
@@ -41,7 +41,7 @@ namespace Discord.Logging
// ignored
}
}
-#if FORMATSTR
+
public async Task LogAsync(LogSeverity severity, string source, FormattableString message, Exception ex = null)
{
try
@@ -51,52 +51,49 @@ namespace Discord.Logging
}
catch { }
}
-#endif
+
public Task ErrorAsync(string source, Exception ex)
=> LogAsync(LogSeverity.Error, source, ex);
public Task ErrorAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Error, source, message, ex);
-#if FORMATSTR
+
public Task ErrorAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Error, source, message, ex);
-#endif
+
public Task WarningAsync(string source, Exception ex)
=> LogAsync(LogSeverity.Warning, source, ex);
public Task WarningAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Warning, source, message, ex);
-#if FORMATSTR
+
public Task WarningAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Warning, source, message, ex);
-#endif
+
public Task InfoAsync(string source, Exception ex)
=> LogAsync(LogSeverity.Info, source, ex);
public Task InfoAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Info, source, message, ex);
-#if FORMATSTR
public Task InfoAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Info, source, message, ex);
-#endif
+
public Task VerboseAsync(string source, Exception ex)
=> LogAsync(LogSeverity.Verbose, source, ex);
public Task VerboseAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Verbose, source, message, ex);
-#if FORMATSTR
public Task VerboseAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Verbose, source, message, ex);
-#endif
+
public Task DebugAsync(string source, Exception ex)
=> LogAsync(LogSeverity.Debug, source, ex);
public Task DebugAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Debug, source, message, ex);
-#if FORMATSTR
public Task DebugAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Debug, source, message, ex);
-#endif
+
public Logger CreateLogger(string name) => new Logger(this, name);
diff --git a/src/Discord.Net.Core/Logging/Logger.cs b/src/Discord.Net.Core/Logging/Logger.cs
index a8d88b2b4..e71c56992 100644
--- a/src/Discord.Net.Core/Logging/Logger.cs
+++ b/src/Discord.Net.Core/Logging/Logger.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Threading.Tasks;
namespace Discord.Logging
@@ -20,54 +20,53 @@ namespace Discord.Logging
=> _manager.LogAsync(severity, Name, exception);
public Task LogAsync(LogSeverity severity, string message, Exception exception = null)
=> _manager.LogAsync(severity, Name, message, exception);
-#if FORMATSTR
public Task LogAsync(LogSeverity severity, FormattableString message, Exception exception = null)
=> _manager.LogAsync(severity, Name, message, exception);
-#endif
+
public Task ErrorAsync(Exception exception)
=> _manager.ErrorAsync(Name, exception);
public Task ErrorAsync(string message, Exception exception = null)
=> _manager.ErrorAsync(Name, message, exception);
-#if FORMATSTR
+
public Task ErrorAsync(FormattableString message, Exception exception = null)
=> _manager.ErrorAsync(Name, message, exception);
-#endif
+
public Task WarningAsync(Exception exception)
=> _manager.WarningAsync(Name, exception);
public Task WarningAsync(string message, Exception exception = null)
=> _manager.WarningAsync(Name, message, exception);
-#if FORMATSTR
+
public Task WarningAsync(FormattableString message, Exception exception = null)
=> _manager.WarningAsync(Name, message, exception);
-#endif
+
public Task InfoAsync(Exception exception)
=> _manager.InfoAsync(Name, exception);
public Task InfoAsync(string message, Exception exception = null)
=> _manager.InfoAsync(Name, message, exception);
-#if FORMATSTR
+
public Task InfoAsync(FormattableString message, Exception exception = null)
=> _manager.InfoAsync(Name, message, exception);
-#endif
+
public Task VerboseAsync(Exception exception)
=> _manager.VerboseAsync(Name, exception);
public Task VerboseAsync(string message, Exception exception = null)
=> _manager.VerboseAsync(Name, message, exception);
-#if FORMATSTR
+
public Task VerboseAsync(FormattableString message, Exception exception = null)
=> _manager.VerboseAsync(Name, message, exception);
-#endif
+
public Task DebugAsync(Exception exception)
=> _manager.DebugAsync(Name, exception);
public Task DebugAsync(string message, Exception exception = null)
=> _manager.DebugAsync(Name, message, exception);
-#if FORMATSTR
+
public Task DebugAsync(FormattableString message, Exception exception = null)
=> _manager.DebugAsync(Name, message, exception);
-#endif
+
}
}
diff --git a/src/Discord.Net.Core/Utils/DateTimeUtils.cs b/src/Discord.Net.Core/Utils/DateTimeUtils.cs
index af2126853..e2a8faa75 100644
--- a/src/Discord.Net.Core/Utils/DateTimeUtils.cs
+++ b/src/Discord.Net.Core/Utils/DateTimeUtils.cs
@@ -1,57 +1,14 @@
-using System;
+using System;
namespace Discord
{
//Source: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/DateTimeOffset.cs
internal static class DateTimeUtils
{
-#if !UNIXTIME
- private const long UnixEpochTicks = 621_355_968_000_000_000;
- private const long UnixEpochSeconds = 62_135_596_800;
- private const long UnixEpochMilliseconds = 62_135_596_800_000;
-#endif
-
public static DateTimeOffset FromTicks(long ticks)
=> new DateTimeOffset(ticks, TimeSpan.Zero);
public static DateTimeOffset? FromTicks(long? ticks)
=> ticks != null ? new DateTimeOffset(ticks.Value, TimeSpan.Zero) : (DateTimeOffset?)null;
-
- public static DateTimeOffset FromUnixSeconds(long seconds)
- {
-#if UNIXTIME
- return DateTimeOffset.FromUnixTimeSeconds(seconds);
-#else
- long ticks = seconds * TimeSpan.TicksPerSecond + UnixEpochTicks;
- return new DateTimeOffset(ticks, TimeSpan.Zero);
-#endif
- }
- public static DateTimeOffset FromUnixMilliseconds(long milliseconds)
- {
-#if UNIXTIME
- return DateTimeOffset.FromUnixTimeMilliseconds(milliseconds);
-#else
- long ticks = milliseconds * TimeSpan.TicksPerMillisecond + UnixEpochTicks;
- return new DateTimeOffset(ticks, TimeSpan.Zero);
-#endif
- }
-
- public static long ToUnixSeconds(DateTimeOffset dto)
- {
-#if UNIXTIME
- return dto.ToUnixTimeSeconds();
-#else
- long seconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerSecond;
- return seconds - UnixEpochSeconds;
-#endif
- }
- public static long ToUnixMilliseconds(DateTimeOffset dto)
- {
-#if UNIXTIME
- return dto.ToUnixTimeMilliseconds();
-#else
- long milliseconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerMillisecond;
- return milliseconds - UnixEpochMilliseconds;
-#endif
- }
+
}
}
diff --git a/src/Discord.Net.Core/Utils/SnowflakeUtils.cs b/src/Discord.Net.Core/Utils/SnowflakeUtils.cs
index c9d0d130b..eecebfb24 100644
--- a/src/Discord.Net.Core/Utils/SnowflakeUtils.cs
+++ b/src/Discord.Net.Core/Utils/SnowflakeUtils.cs
@@ -5,8 +5,8 @@ namespace Discord
public static class SnowflakeUtils
{
public static DateTimeOffset FromSnowflake(ulong value)
- => DateTimeUtils.FromUnixMilliseconds((long)((value >> 22) + 1420070400000UL));
+ => DateTimeOffset.FromUnixTimeMilliseconds((long)((value >> 22) + 1420070400000UL));
public static ulong ToSnowflake(DateTimeOffset value)
- => ((ulong)DateTimeUtils.ToUnixMilliseconds(value) - 1420070400000UL) << 22;
+ => ((ulong)value.ToUnixTimeMilliseconds() - 1420070400000UL) << 22;
}
}
diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
index bae677148..05cdf4b8a 100644
--- a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CS1591
using Newtonsoft.Json;
namespace Discord.API.Rest
@@ -10,9 +10,20 @@ namespace Discord.API.Rest
public string Name { get; }
[JsonProperty("type")]
public ChannelType Type { get; }
+ [JsonProperty("parent_id")]
+ public Optional CategoryId { get; set; }
+ //Text channels
+ [JsonProperty("topic")]
+ public Optional Topic { get; set; }
+ [JsonProperty("nsfw")]
+ public Optional IsNsfw { get; set; }
+
+ //Voice channels
[JsonProperty("bitrate")]
public Optional Bitrate { get; set; }
+ [JsonProperty("user_limit")]
+ public Optional UserLimit { get; set; }
public CreateGuildChannelParams(string name, ChannelType type)
{
diff --git a/src/Discord.Net.Rest/API/Rest/GetReactionUsersParams.cs b/src/Discord.Net.Rest/API/Rest/GetReactionUsersParams.cs
index d70da5632..a0967bb75 100644
--- a/src/Discord.Net.Rest/API/Rest/GetReactionUsersParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/GetReactionUsersParams.cs
@@ -1,4 +1,4 @@
-namespace Discord.API.Rest
+namespace Discord.API.Rest
{
internal class GetReactionUsersParams
{
diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.csproj b/src/Discord.Net.Rest/Discord.Net.Rest.csproj
index 0eb07a4b2..75b69bd04 100644
--- a/src/Discord.Net.Rest/Discord.Net.Rest.csproj
+++ b/src/Discord.Net.Rest/Discord.Net.Rest.csproj
@@ -1,20 +1,19 @@
-
+
Discord.Net.Rest
Discord.Rest
A core Discord.Net library containing the REST client and models.
- net45;netstandard1.1;netstandard1.3
- netstandard1.1;netstandard1.3
+ net46;netstandard1.3;netstandard2.0
+ netstandard1.3;netstandard2.0
-
-
-
+
+
-
+
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index f23547106..70a2acd15 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -630,11 +630,11 @@ namespace Discord.API
Preconditions.NotNullOrWhitespace(emoji, nameof(emoji));
Preconditions.NotNull(args, nameof(args));
Preconditions.GreaterThan(args.Limit, 0, nameof(args.Limit));
- Preconditions.AtMost(args.Limit, DiscordConfig.MaxUsersPerBatch, nameof(args.Limit));
+ Preconditions.AtMost(args.Limit, DiscordConfig.MaxUserReactionsPerBatch, nameof(args.Limit));
Preconditions.GreaterThan(args.AfterUserId, 0, nameof(args.AfterUserId));
options = RequestOptions.CreateOrClone(options);
- int limit = args.Limit.GetValueOrDefault(int.MaxValue);
+ int limit = args.Limit.GetValueOrDefault(DiscordConfig.MaxUserReactionsPerBatch);
ulong afterUserId = args.AfterUserId.GetValueOrDefault(0);
var ids = new BucketIds(channelId: channelId);
diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
index 6a3521bff..62764a05d 100644
--- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
@@ -162,7 +162,6 @@ namespace Discord.Rest
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
}
-#if FILESYSTEM
///
/// is a zero-length string, contains only white space, or contains one or more
/// invalid characters as defined by .
@@ -194,7 +193,7 @@ namespace Discord.Rest
using (var file = File.OpenRead(filePath))
return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, options).ConfigureAwait(false);
}
-#endif
+
/// Message content is too long, length must be less or equal to .
public static async Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
@@ -204,6 +203,10 @@ namespace Discord.Rest
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
}
+ public static Task DeleteMessageAsync(IMessageChannel channel, ulong messageId, BaseDiscordClient client,
+ RequestOptions options)
+ => MessageHelper.DeleteAsync(channel.Id, messageId, client, options);
+
public static async Task DeleteMessagesAsync(ITextChannel channel, BaseDiscordClient client,
IEnumerable messageIds, RequestOptions options)
{
diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
index b0eed8b25..ac2f27bbd 100644
--- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
@@ -19,8 +19,7 @@ namespace Discord.Rest
///
/// An awaitable Task containing the message sent to the channel.
///
- new Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#if FILESYSTEM
+ new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
///
/// Sends a file to this message channel, with an optional caption.
///
@@ -38,7 +37,6 @@ namespace Discord.Rest
/// An awaitable Task containing the message sent to the channel.
///
new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#endif
///
/// Sends a file to this message channel, with an optional caption.
///
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
index a3161c72c..7af228654 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
@@ -74,17 +74,21 @@ namespace Discord.Rest
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
///
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
///
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
///
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
///
public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options);
@@ -143,12 +147,9 @@ namespace Discord.Rest
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
- ///
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
- ///
+
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
///
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
index 4b4ccb057..f69b048d8 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
@@ -83,11 +83,16 @@ namespace Discord.Rest
public Task> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
///
/// Message content is too long, length must be less or equal to .
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
///
///
/// is a zero-length string, contains only white space, or contains one or more
@@ -115,7 +120,6 @@ namespace Discord.Rest
/// Message content is too long, length must be less or equal to .
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
///
/// Message content is too long, length must be less or equal to .
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
@@ -168,10 +172,9 @@ namespace Discord.Rest
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
+
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
index 9752697d6..332fb0679 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
@@ -58,15 +58,20 @@ namespace Discord.Rest
public Task> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
+
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
public Task DeleteMessagesAsync(IEnumerable messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages.Select(x => x.Id), options);
public Task DeleteMessagesAsync(IEnumerable messageIds, RequestOptions options = null)
@@ -126,10 +131,9 @@ namespace Discord.Rest
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
+
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
diff --git a/src/Discord.Net.Rest/Entities/Channels/RpcVirtualMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RpcVirtualMessageChannel.cs
index 049f86c08..0643ecf6c 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RpcVirtualMessageChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RpcVirtualMessageChannel.cs
@@ -33,15 +33,19 @@ namespace Discord.Rest
public Task> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
- public Task SendMessageAsync(string text, bool isTTS, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
- public Task SendFileAsync(string filePath, string text, bool isTTS, Embed embed = null, RequestOptions options = null)
+ public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
- public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed = null, RequestOptions options = null)
+ public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options);
public IDisposable EnterTypingState(RequestOptions options = null)
@@ -81,10 +85,9 @@ namespace Discord.Rest
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
- => await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
+ => await SendFileAsync(filePath, text, isTTS, embed, options);
+
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index 64f195a0d..195e6f3c0 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -147,21 +147,37 @@ namespace Discord.Rest
}
/// is null.
public static async Task CreateTextChannelAsync(IGuild guild, BaseDiscordClient client,
- string name, RequestOptions options)
+ string name, RequestOptions options, Action func = null)
{
if (name == null) throw new ArgumentNullException(nameof(name));
- var args = new CreateGuildChannelParams(name, ChannelType.Text);
+ var props = new TextChannelProperties();
+ func?.Invoke(props);
+
+ var args = new CreateGuildChannelParams(name, ChannelType.Text)
+ {
+ CategoryId = props.CategoryId,
+ Topic = props.Topic,
+ IsNsfw = props.IsNsfw
+ };
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestTextChannel.Create(client, guild, model);
}
/// is null.
public static async Task CreateVoiceChannelAsync(IGuild guild, BaseDiscordClient client,
- string name, RequestOptions options)
+ string name, RequestOptions options, Action func = null)
{
if (name == null) throw new ArgumentNullException(nameof(name));
- var args = new CreateGuildChannelParams(name, ChannelType.Voice);
+ var props = new VoiceChannelProperties();
+ func?.Invoke(props);
+
+ var args = new CreateGuildChannelParams(name, ChannelType.Voice)
+ {
+ CategoryId = props.CategoryId,
+ Bitrate = props.Bitrate,
+ UserLimit = props.UserLimit
+ };
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestVoiceChannel.Create(client, guild, model);
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index e301db892..e003e2130 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -258,10 +258,10 @@ namespace Discord.Rest
}
return null;
}
- public Task CreateTextChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
- public Task CreateVoiceChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options);
+ public Task CreateTextChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func);
+ public Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func);
public Task CreateCategoryChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);
@@ -448,11 +448,11 @@ namespace Discord.Rest
return null;
}
///
- async Task IGuild.CreateTextChannelAsync(string name, RequestOptions options)
- => await CreateTextChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateTextChannelAsync(string name, Action func, RequestOptions options)
+ => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false);
///
- async Task IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
- => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options)
+ => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
///
async Task IGuild.CreateCategoryAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);
diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
index 34e64cd5a..ac1eacc3a 100644
--- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
@@ -27,10 +27,12 @@ namespace Discord.Rest
};
return await client.ApiClient.ModifyMessageAsync(msg.Channel.Id, msg.Id, apiArgs, options).ConfigureAwait(false);
}
- public static async Task DeleteAsync(IMessage msg, BaseDiscordClient client,
+ public static Task DeleteAsync(IMessage msg, BaseDiscordClient client, RequestOptions options)
+ => DeleteAsync(msg.Channel.Id, msg.Id, client, options);
+ public static async Task DeleteAsync(ulong channelId, ulong msgId, BaseDiscordClient client,
RequestOptions options)
{
- await client.ApiClient.DeleteMessageAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
+ await client.ApiClient.DeleteMessageAsync(channelId, msgId, options).ConfigureAwait(false);
}
public static async Task AddReactionAsync(IMessage msg, IEmote emote, BaseDiscordClient client, RequestOptions options)
@@ -48,13 +50,38 @@ namespace Discord.Rest
await client.ApiClient.RemoveAllReactionsAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
}
- public static async Task> GetReactionUsersAsync(IMessage msg, IEmote emote,
- Action func, BaseDiscordClient client, RequestOptions options)
+ public static IAsyncEnumerable> GetReactionUsersAsync(IMessage msg, IEmote emote,
+ int? limit, BaseDiscordClient client, RequestOptions options)
{
- var args = new GetReactionUsersParams();
- func(args);
- string emoji = (emote is Emote e ? $"{e.Name}:{e.Id}" : emote.Name);
- return (await client.ApiClient.GetReactionUsersAsync(msg.Channel.Id, msg.Id, emoji, args, options).ConfigureAwait(false)).Select(u => RestUser.Create(client, u)).ToImmutableArray();
+ Preconditions.NotNull(emote, nameof(emote));
+ var emoji = (emote is Emote e ? $"{e.Name}:{e.Id}" : emote.Name);
+
+ return new PagedAsyncEnumerable(
+ DiscordConfig.MaxUserReactionsPerBatch,
+ async (info, ct) =>
+ {
+ var args = new GetReactionUsersParams
+ {
+ Limit = info.PageSize
+ };
+
+ if (info.Position != null)
+ args.AfterUserId = info.Position.Value;
+
+ var models = await client.ApiClient.GetReactionUsersAsync(msg.Channel.Id, msg.Id, emoji, args, options).ConfigureAwait(false);
+ return models.Select(x => RestUser.Create(client, x)).ToImmutableArray();
+ },
+ nextPage: (info, lastPage) =>
+ {
+ if (lastPage.Count != DiscordConfig.MaxUsersPerBatch)
+ return false;
+
+ info.Position = lastPage.Max(x => x.Id);
+ return true;
+ },
+ count: limit
+ );
+
}
public static async Task PinAsync(IMessage msg, BaseDiscordClient client,
diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
index de295af94..7e000fd5f 100644
--- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
@@ -151,9 +151,9 @@ namespace Discord.Rest
public Task RemoveAllReactionsAsync(RequestOptions options = null)
=> MessageHelper.RemoveAllReactionsAsync(this, Discord, options);
///
- public Task> GetReactionUsersAsync(IEmote emote, int limit = 100, ulong? afterUserId = null, RequestOptions options = null)
- => MessageHelper.GetReactionUsersAsync(this, emote, x => { x.Limit = limit; x.AfterUserId = afterUserId ?? Optional.Create(); }, Discord, options);
-
+ public IAsyncEnumerable> GetReactionUsersAsync(IEmote emote, int limit, RequestOptions options = null)
+ => MessageHelper.GetReactionUsersAsync(this, emote, limit, Discord, options);
+
///
public Task PinAsync(RequestOptions options = null)
=> MessageHelper.PinAsync(this, Discord, options);
diff --git a/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs b/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs
index 9213c5d75..8a3c1037b 100644
--- a/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs
+++ b/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs
@@ -1,4 +1,4 @@
-using Discord.API;
+using Discord.API;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
@@ -25,7 +25,6 @@ namespace Discord.Net.Converters
if (converter != null)
{
property.Converter = converter;
- property.MemberConverter = converter;
}
}
else
diff --git a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
index 5894aa768..a4f87a3e9 100644
--- a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
+++ b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
@@ -230,7 +230,7 @@ namespace Discord.Net.Queue
#endif
}
- var now = DateTimeUtils.ToUnixSeconds(DateTimeOffset.UtcNow);
+ var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
DateTimeOffset? resetTick = null;
//Using X-RateLimit-Remaining causes a race condition
diff --git a/src/Discord.Net.Rest/Net/RateLimitInfo.cs b/src/Discord.Net.Rest/Net/RateLimitInfo.cs
index e9a5fde9e..d31cc5cdd 100644
--- a/src/Discord.Net.Rest/Net/RateLimitInfo.cs
+++ b/src/Discord.Net.Rest/Net/RateLimitInfo.cs
@@ -21,7 +21,7 @@ namespace Discord.Net
Remaining = headers.TryGetValue("X-RateLimit-Remaining", out temp) &&
int.TryParse(temp, out var remaining) ? remaining : (int?)null;
Reset = headers.TryGetValue("X-RateLimit-Reset", out temp) &&
- int.TryParse(temp, out var reset) ? DateTimeUtils.FromUnixSeconds(reset) : (DateTimeOffset?)null;
+ int.TryParse(temp, out var reset) ? DateTimeOffset.FromUnixTimeSeconds(reset) : (DateTimeOffset?)null;
RetryAfter = headers.TryGetValue("Retry-After", out temp) &&
int.TryParse(temp, out var retryAfter) ? retryAfter : (int?)null;
Lag = headers.TryGetValue("Date", out temp) &&
diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
index 251cdb18b..ddd3b7954 100644
--- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
+++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
@@ -1,11 +1,11 @@
-
+
Discord.Net.WebSocket
Discord.WebSocket
A core Discord.Net library containing the WebSocket client and models.
- net45;netstandard1.1;netstandard1.3
- netstandard1.1;netstandard1.3
+ net46;netstandard1.3;netstandard2.0
+ netstandard1.3;netstandard2.0
true
@@ -13,6 +13,6 @@
-
+
diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
index dc4e72020..721181968 100644
--- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
@@ -378,7 +378,7 @@ namespace Discord.WebSocket
await ApiClient.SendStatusUpdateAsync(
status,
status == UserStatus.AFK,
- statusSince != null ? DateTimeUtils.ToUnixMilliseconds(_statusSince.Value) : (long?)null,
+ statusSince != null ? _statusSince.Value.ToUnixTimeMilliseconds() : (long?)null,
gameModel).ConfigureAwait(false);
}
diff --git a/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs b/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs
index 25dc2cf7b..0eb92caed 100644
--- a/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CS1591
using Discord.API;
using Discord.API.Voice;
using Discord.Net.Converters;
@@ -129,7 +129,7 @@ namespace Discord.Audio
//WebSocket
public async Task SendHeartbeatAsync(RequestOptions options = null)
{
- await SendAsync(VoiceOpCode.Heartbeat, DateTimeUtils.ToUnixMilliseconds(DateTimeOffset.UtcNow), options: options).ConfigureAwait(false);
+ await SendAsync(VoiceOpCode.Heartbeat, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), options: options).ConfigureAwait(false);
}
public async Task SendIdentityAsync(ulong userId, string sessionId, string token)
{
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs
index c37311a41..73fc3c34c 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs
@@ -28,8 +28,7 @@ namespace Discord.WebSocket
///
/// An awaitable Task containing the message sent to the channel.
///
- new Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#if FILESYSTEM
+ new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
///
/// Sends a file to this message channel, with an optional caption.
///
@@ -47,7 +46,6 @@ namespace Discord.WebSocket
/// An awaitable Task containing the message sent to the channel.
///
new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
-#endif
///
/// Sends a file to this message channel, with an optional caption.
///
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs
index 763296590..af8854f21 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs
@@ -79,18 +79,22 @@ namespace Discord.WebSocket
///
/// Message content is too long, length must be less or equal to .
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
///
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
///
/// Message content is too long, length must be less or equal to .
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
///
public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options);
@@ -160,12 +164,8 @@ namespace Discord.WebSocket
///
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
- ///
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
- ///
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
///
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
index 57fcc51a2..5eb2a6e12 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
@@ -109,17 +109,21 @@ namespace Discord.WebSocket
///
/// Message content is too long, length must be less or equal to .
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
///
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
///
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
///
public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options);
@@ -235,11 +239,10 @@ namespace Discord.WebSocket
///
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
+
///
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
///
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs
index 92bc07c60..c06d093e8 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs
@@ -90,13 +90,12 @@ namespace Discord.WebSocket
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
///
- public Task SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
-#if FILESYSTEM
+
///
public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
-#endif
///
public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);
@@ -108,6 +107,11 @@ namespace Discord.WebSocket
public Task DeleteMessagesAsync(IEnumerable messageIds, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messageIds, options);
+ public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
+ public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
+ => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);
+
///
public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options);
@@ -209,11 +213,10 @@ namespace Discord.WebSocket
///
async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
-#if FILESYSTEM
+
///
async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false);
-#endif
///
async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index ca8f54d0b..81106ec48 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -463,9 +463,8 @@ namespace Discord.WebSocket
///
/// The created text channel.
///
- public Task CreateTextChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
-
+ public Task CreateTextChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func);
///
/// Creates a voice channel with the provided name.
///
@@ -475,9 +474,8 @@ namespace Discord.WebSocket
///
/// The created voice channel.
///
- public Task CreateVoiceChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options);
-
+ public Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func);
///
/// Creates a category channel with the provided name.
///
@@ -930,11 +928,11 @@ namespace Discord.WebSocket
Task IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult(SystemChannel);
///
- async Task IGuild.CreateTextChannelAsync(string name, RequestOptions options)
- => await CreateTextChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateTextChannelAsync(string name, Action func, RequestOptions options)
+ => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false);
///
- async Task IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
- => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options)
+ => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
///
async Task IGuild.CreateCategoryAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);
diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
index d22464652..7730e5363 100644
--- a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
+++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
@@ -150,8 +150,8 @@ namespace Discord.WebSocket
public Task RemoveAllReactionsAsync(RequestOptions options = null)
=> MessageHelper.RemoveAllReactionsAsync(this, Discord, options);
///
- public Task> GetReactionUsersAsync(IEmote emote, int limit = 100, ulong? afterUserId = null, RequestOptions options = null)
- => MessageHelper.GetReactionUsersAsync(this, emote, x => { x.Limit = limit; x.AfterUserId = afterUserId ?? Optional.Create(); }, Discord, options);
+ public IAsyncEnumerable> GetReactionUsersAsync(IEmote emote, int limit, RequestOptions options = null)
+ => MessageHelper.GetReactionUsersAsync(this, emote, limit, Discord, options);
///
public Task PinAsync(RequestOptions options = null)
diff --git a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs
index 6a6194397..251a761d4 100644
--- a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs
+++ b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs
@@ -1,4 +1,3 @@
-#if DEFAULTUDPCLIENT
using System;
using System.Net;
using System.Net.Sockets;
@@ -85,11 +84,7 @@ namespace Discord.Net.Udp
if (_udp != null)
{
-#if UDPDISPOSE
try { _udp.Dispose(); }
-#else
- try { _udp.Close(); }
-#endif
catch { }
_udp = null;
}
@@ -132,4 +127,3 @@ namespace Discord.Net.Udp
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs b/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs
index 82b6ec4c0..d701fa79a 100644
--- a/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs
+++ b/src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs
@@ -4,7 +4,6 @@ namespace Discord.Net.Udp
{
public static class DefaultUdpSocketProvider
{
-#if DEFAULTUDPCLIENT
public static readonly UdpSocketProvider Instance = () =>
{
try
@@ -16,12 +15,5 @@ namespace Discord.Net.Udp
throw new PlatformNotSupportedException("The default UdpSocketProvider is not supported on this platform.", ex);
}
};
-#else
- public static readonly UdpSocketProvider Instance = () =>
- {
- throw new PlatformNotSupportedException("The default UdpSocketProvider is not supported on this platform.\n" +
- "You must specify a UdpSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
- };
-#endif
}
-}
\ No newline at end of file
+}
diff --git a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs
index 2301d3e45..c60368da0 100644
--- a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs
+++ b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClient.cs
@@ -1,4 +1,3 @@
-#if DEFAULTWEBSOCKET
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -209,14 +208,9 @@ namespace Discord.Net.WebSockets
//Use the internal buffer if we can get it
resultCount = (int)stream.Length;
-#if MSTRYBUFFER
- if (stream.TryGetBuffer(out var streamBuffer))
- result = streamBuffer.Array;
- else
- result = stream.ToArray();
-#else
- result = stream.GetBuffer();
-#endif
+
+ result = stream.TryGetBuffer(out var streamBuffer) ? streamBuffer.Array : stream.ToArray();
+
}
}
else
@@ -248,4 +242,3 @@ namespace Discord.Net.WebSockets
}
}
}
-#endif
diff --git a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClientProvider.cs b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClientProvider.cs
index ca05d1c56..bc580c410 100644
--- a/src/Discord.Net.WebSocket/Net/DefaultWebSocketClientProvider.cs
+++ b/src/Discord.Net.WebSocket/Net/DefaultWebSocketClientProvider.cs
@@ -5,7 +5,6 @@ namespace Discord.Net.WebSockets
{
public static class DefaultWebSocketProvider
{
-#if DEFAULTWEBSOCKET
public static readonly WebSocketProvider Instance = Create();
/// The default WebSocketProvider is not supported on this platform.
@@ -23,12 +22,5 @@ namespace Discord.Net.WebSockets
}
};
}
-#else
- public static readonly WebSocketProvider Instance = () =>
- {
- throw new PlatformNotSupportedException("The default WebSocketProvider is not supported on this platform.\n" +
- "You must specify a WebSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
- };
-#endif
}
}
diff --git a/src/Discord.Net.Webhook/Discord.Net.Webhook.csproj b/src/Discord.Net.Webhook/Discord.Net.Webhook.csproj
index a35e5d578..ba7bbcff8 100644
--- a/src/Discord.Net.Webhook/Discord.Net.Webhook.csproj
+++ b/src/Discord.Net.Webhook/Discord.Net.Webhook.csproj
@@ -1,10 +1,10 @@
-
+
Discord.Net.Webhook
Discord.Webhook
A core Discord.Net library containing the Webhook client and models.
- netstandard1.1;netstandard1.3
+ netstandard1.3
diff --git a/src/Discord.Net.Webhook/DiscordWebhookClient.cs b/src/Discord.Net.Webhook/DiscordWebhookClient.cs
index 088988c9a..16841e936 100644
--- a/src/Discord.Net.Webhook/DiscordWebhookClient.cs
+++ b/src/Discord.Net.Webhook/DiscordWebhookClient.cs
@@ -62,20 +62,17 @@ namespace Discord.Webhook
}
private static API.DiscordRestApiClient CreateApiClient(DiscordRestConfig config)
=> new API.DiscordRestApiClient(config.RestClientProvider, DiscordRestConfig.UserAgent);
-
/// Sends a message using to the channel for this webhook.
/// Returns the ID of the created message.
- public Task SendMessageAsync(string text, bool isTTS = false, IEnumerable
-
-
-
-
-
+
+
+
+
+
diff --git a/test/Discord.Net.Tests/Tests.ChannelPermissions.cs b/test/Discord.Net.Tests/Tests.ChannelPermissions.cs
index b37a1195e..da969b320 100644
--- a/test/Discord.Net.Tests/Tests.ChannelPermissions.cs
+++ b/test/Discord.Net.Tests/Tests.ChannelPermissions.cs
@@ -84,7 +84,7 @@ namespace Discord
Assert.Equal(groupChannel, ChannelPermissions.Group.RawValue);
return Task.CompletedTask;
}
-
+ [Fact]
public Task TestChannelPermissionModify()
{
// test channel permission modify
diff --git a/test/Discord.Net.Tests/Tests.Channels.cs b/test/Discord.Net.Tests/Tests.Channels.cs
index b528ca5fb..cd629faa4 100644
--- a/test/Discord.Net.Tests/Tests.Channels.cs
+++ b/test/Discord.Net.Tests/Tests.Channels.cs
@@ -49,35 +49,35 @@ namespace Discord
}
private static void CheckTextChannels(RestGuild guild, params RestTextChannel[] textChannels)
{
- Assert.Equal(textChannels.Length, 5);
+ Assert.Equal(5, textChannels.Length);
Assert.All(textChannels, x =>
{
Assert.NotNull(x);
- Assert.NotEqual(x.Id, 0UL);
+ Assert.NotEqual(0UL, x.Id);
Assert.True(x.Position >= 0);
});
- var text1 = textChannels.Where(x => x.Name == "text1").FirstOrDefault();
- var text2 = textChannels.Where(x => x.Name == "text2").FirstOrDefault();
- var text3 = textChannels.Where(x => x.Name == "text3").FirstOrDefault();
- var text4 = textChannels.Where(x => x.Name == "text4").FirstOrDefault();
- var text5 = textChannels.Where(x => x.Name == "text5").FirstOrDefault();
+ var text1 = textChannels.FirstOrDefault(x => x.Name == "text1");
+ var text2 = textChannels.FirstOrDefault(x => x.Name == "text2");
+ var text3 = textChannels.FirstOrDefault(x => x.Name == "text3");
+ var text4 = textChannels.FirstOrDefault(x => x.Name == "text4");
+ var text5 = textChannels.FirstOrDefault(x => x.Name == "text5");
Assert.NotNull(text1);
//Assert.True(text1.Id == guild.DefaultChannelId);
- Assert.Equal(text1.Position, 1);
- Assert.Equal(text1.Topic, "Topic1");
+ Assert.Equal(1, text1.Position);
+ Assert.Equal("Topic1", text1.Topic);
Assert.NotNull(text2);
- Assert.Equal(text2.Position, 2);
+ Assert.Equal(2, text2.Position);
Assert.Null(text2.Topic);
Assert.NotNull(text3);
- Assert.Equal(text3.Topic, "Topic2");
+ Assert.Equal("Topic2", text3.Topic);
Assert.NotNull(text4);
- Assert.Equal(text4.Position, 3);
- Assert.Equal(text4.Topic, "Topic2");
+ Assert.Equal(3, text4.Position);
+ Assert.Equal("Topic2", text4.Topic);
Assert.NotNull(text5);
Assert.Null(text5.Topic);
@@ -114,31 +114,31 @@ namespace Discord
}
private static void CheckVoiceChannels(params RestVoiceChannel[] voiceChannels)
{
- Assert.Equal(voiceChannels.Length, 3);
+ Assert.Equal(3, voiceChannels.Length);
Assert.All(voiceChannels, x =>
{
Assert.NotNull(x);
- Assert.NotEqual(x.Id, 0UL);
- Assert.NotEqual(x.UserLimit, 0);
+ Assert.NotEqual(0UL, x.Id);
+ Assert.NotEqual(0, x.UserLimit);
Assert.True(x.Bitrate > 0);
Assert.True(x.Position >= 0);
});
- var voice1 = voiceChannels.Where(x => x.Name == "voice1").FirstOrDefault();
- var voice2 = voiceChannels.Where(x => x.Name == "voice2").FirstOrDefault();
- var voice3 = voiceChannels.Where(x => x.Name == "voice3").FirstOrDefault();
+ var voice1 = voiceChannels.FirstOrDefault(x => x.Name == "voice1");
+ var voice2 = voiceChannels.FirstOrDefault(x => x.Name == "voice2");
+ var voice3 = voiceChannels.FirstOrDefault(x => x.Name == "voice3");
Assert.NotNull(voice1);
- Assert.Equal(voice1.Bitrate, 96000);
- Assert.Equal(voice1.Position, 1);
+ Assert.Equal(96000, voice1.Bitrate);
+ Assert.Equal(1, voice1.Position);
Assert.NotNull(voice2);
- Assert.Equal(voice2.UserLimit, null);
+ Assert.Null(voice2.UserLimit);
Assert.NotNull(voice3);
- Assert.Equal(voice3.Bitrate, 8000);
- Assert.Equal(voice3.Position, 1);
- Assert.Equal(voice3.UserLimit, 16);
+ Assert.Equal(8000, voice3.Bitrate);
+ Assert.Equal(1, voice3.Position);
+ Assert.Equal(16, voice3.UserLimit);
}
}
-}
\ No newline at end of file
+}
diff --git a/test/Discord.Net.Tests/Tests.Colors.cs b/test/Discord.Net.Tests/Tests.Colors.cs
index 591778972..10b0bbdac 100644
--- a/test/Discord.Net.Tests/Tests.Colors.cs
+++ b/test/Discord.Net.Tests/Tests.Colors.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Xunit;
namespace Discord
@@ -12,6 +12,7 @@ namespace Discord
Assert.Equal(uint.MinValue, new Color(uint.MinValue).RawValue);
Assert.Equal(uint.MaxValue, new Color(uint.MaxValue).RawValue);
}
+ [Fact]
public void Color_Default()
{
Assert.Equal(0u, Color.Default.RawValue);
diff --git a/test/Discord.Net.Tests/Tests.Emotes.cs b/test/Discord.Net.Tests/Tests.Emotes.cs
index 334975ce4..eeadbddf8 100644
--- a/test/Discord.Net.Tests/Tests.Emotes.cs
+++ b/test/Discord.Net.Tests/Tests.Emotes.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Xunit;
namespace Discord
@@ -34,6 +34,7 @@ namespace Discord
Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1514056829775), emote.CreatedAt);
Assert.EndsWith("gif", emote.Url);
}
+ [Fact]
public void Test_Invalid_Amimated_Emote_Parse()
{
Assert.False(Emote.TryParse("", out _));
diff --git a/test/Discord.Net.Tests/Tests.GuildPermissions.cs b/test/Discord.Net.Tests/Tests.GuildPermissions.cs
index a562f4afb..2b7c39341 100644
--- a/test/Discord.Net.Tests/Tests.GuildPermissions.cs
+++ b/test/Discord.Net.Tests/Tests.GuildPermissions.cs
@@ -138,12 +138,12 @@ namespace Discord
// individual permission test
- perm = perm.Modify(readMessages: true);
- Assert.True(perm.ReadMessages);
- Assert.Equal(perm.RawValue, (ulong)GuildPermission.ReadMessages);
+ perm = perm.Modify(viewChannel: true);
+ Assert.True(perm.ViewChannel);
+ Assert.Equal(perm.RawValue, (ulong)GuildPermission.ViewChannel);
- perm = perm.Modify(readMessages: false);
- Assert.False(perm.ReadMessages);
+ perm = perm.Modify(viewChannel: false);
+ Assert.False(perm.ViewChannel);
Assert.Equal(GuildPermissions.None.RawValue, perm.RawValue);
diff --git a/test/Discord.Net.Tests/Tests.Permissions.cs b/test/Discord.Net.Tests/Tests.Permissions.cs
index e22659d15..0516337da 100644
--- a/test/Discord.Net.Tests/Tests.Permissions.cs
+++ b/test/Discord.Net.Tests/Tests.Permissions.cs
@@ -25,15 +25,15 @@ namespace Discord
// check that toggling the bit works
Permissions.UnsetFlag(ref rawValue, flagValue);
- Assert.Equal(false, Permissions.GetValue(rawValue, flagValue));
+ Assert.False(Permissions.GetValue(rawValue, flagValue));
Permissions.SetFlag(ref rawValue, flagValue);
- Assert.Equal(true, Permissions.GetValue(rawValue, flagValue));
+ Assert.True(Permissions.GetValue(rawValue, flagValue));
// do the same, but with the SetValue method
Permissions.SetValue(ref rawValue, true, flagValue);
- Assert.Equal(true, Permissions.GetValue(rawValue, flagValue));
+ Assert.True(Permissions.GetValue(rawValue, flagValue));
Permissions.SetValue(ref rawValue, false, flagValue);
- Assert.Equal(false, Permissions.GetValue(rawValue, flagValue));
+ Assert.False(Permissions.GetValue(rawValue, flagValue));
}
///
@@ -280,7 +280,7 @@ namespace Discord
TestHelper(value, GuildPermission.ManageGuild, false);
TestHelper(value, GuildPermission.AddReactions, false);
TestHelper(value, GuildPermission.ViewAuditLog, false);
- TestHelper(value, GuildPermission.ReadMessages, false);
+ TestHelper(value, GuildPermission.ViewChannel, false);
TestHelper(value, GuildPermission.SendMessages, false);
TestHelper(value, GuildPermission.SendTTSMessages, false);
TestHelper(value, GuildPermission.ManageMessages, false);
@@ -323,7 +323,7 @@ namespace Discord
TestHelper(value, GuildPermission.ManageGuild, true);
TestHelper(value, GuildPermission.AddReactions, true);
TestHelper(value, GuildPermission.ViewAuditLog, true);
- TestHelper(value, GuildPermission.ReadMessages, true);
+ TestHelper(value, GuildPermission.ViewChannel, true);
TestHelper(value, GuildPermission.SendMessages, true);
TestHelper(value, GuildPermission.SendTTSMessages, true);
TestHelper(value, GuildPermission.ManageMessages, true);
@@ -367,7 +367,7 @@ namespace Discord
TestHelper(value, GuildPermission.ManageGuild, false);
TestHelper(value, GuildPermission.AddReactions, false);
TestHelper(value, GuildPermission.ViewAuditLog, false);
- TestHelper(value, GuildPermission.ReadMessages, false);
+ TestHelper(value, GuildPermission.ViewChannel, false);
TestHelper(value, GuildPermission.SendMessages, true);
TestHelper(value, GuildPermission.SendTTSMessages, true);
TestHelper(value, GuildPermission.ManageMessages, false);