@@ -1,4 +1,3 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
@@ -1,7 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | |||||
using System.Globalization; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
@@ -1,5 +1,4 @@ | |||||
using Discord.Audio; | using Discord.Audio; | ||||
using System; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord | namespace Discord | ||||
@@ -1,7 +1,17 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | |||||
/// Provides extension methods for <see cref="IMessage"/>. | |||||
/// </summary> | |||||
public static class MessageExtensions | public static class MessageExtensions | ||||
{ | { | ||||
/// <summary> | |||||
/// Gets a URL that jumps to the message. | |||||
/// </summary> | |||||
/// <param name="msg">The message to jump to.</param> | |||||
/// <returns> | |||||
/// A string that contains a URL for jumping to the message in chat. | |||||
/// </returns> | |||||
public static string GetJumpUrl(this IMessage msg) | public static string GetJumpUrl(this IMessage msg) | ||||
{ | { | ||||
var channel = msg.Channel; | var channel = msg.Channel; | ||||
@@ -10,6 +10,19 @@ namespace Discord | |||||
/// <summary> | /// <summary> | ||||
/// Sends a message via DM. | /// Sends a message via DM. | ||||
/// </summary> | /// </summary> | ||||
/// <remarks> | |||||
/// This method attempts to send a direct-message to the user. | |||||
/// <note type="warning"> | |||||
/// <para> | |||||
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/> | |||||
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked. | |||||
/// </para> | |||||
/// <para> | |||||
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/> | |||||
/// <c>50007</c> when using this method. | |||||
/// </para> | |||||
/// </note> | |||||
/// </remarks> | |||||
/// <param name="user">The user to send the DM to.</param> | /// <param name="user">The user to send the DM to.</param> | ||||
/// <param name="text">The message to be sent.</param> | /// <param name="text">The message to be sent.</param> | ||||
/// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | /// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | ||||
@@ -30,6 +43,19 @@ namespace Discord | |||||
/// <summary> | /// <summary> | ||||
/// Sends a file to this message channel with an optional caption. | /// Sends a file to this message channel with an optional caption. | ||||
/// </summary> | /// </summary> | ||||
/// <remarks> | |||||
/// This method attempts to send an attachment as a direct-message to the user. | |||||
/// <note type="warning"> | |||||
/// <para> | |||||
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/> | |||||
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked. | |||||
/// </para> | |||||
/// <para> | |||||
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/> | |||||
/// <c>50007</c> when using this method. | |||||
/// </para> | |||||
/// </note> | |||||
/// </remarks> | |||||
/// <param name="user">The user to send the DM to.</param> | /// <param name="user">The user to send the DM to.</param> | ||||
/// <param name="stream">The <see cref="Stream"/> of the file to be sent.</param> | /// <param name="stream">The <see cref="Stream"/> of the file to be sent.</param> | ||||
/// <param name="filename">The name of the attachment.</param> | /// <param name="filename">The name of the attachment.</param> | ||||
@@ -60,6 +86,19 @@ namespace Discord | |||||
/// <summary> | /// <summary> | ||||
/// Sends a file via DM with an optional caption. | /// Sends a file via DM with an optional caption. | ||||
/// </summary> | /// </summary> | ||||
/// <remarks> | |||||
/// This method attempts to send an attachment as a direct-message to the user. | |||||
/// <note type="warning"> | |||||
/// <para> | |||||
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/> | |||||
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked. | |||||
/// </para> | |||||
/// <para> | |||||
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/> | |||||
/// <c>50007</c> when using this method. | |||||
/// </para> | |||||
/// </note> | |||||
/// </remarks> | |||||
/// <param name="user">The user to send the DM to.</param> | /// <param name="user">The user to send the DM to.</param> | ||||
/// <param name="filePath">The file path of the file.</param> | /// <param name="filePath">The file path of the file.</param> | ||||
/// <param name="text">The message to be sent.</param> | /// <param name="text">The message to be sent.</param> | ||||
@@ -1,4 +1,4 @@ | |||||
using Discord.Net.WebSockets; | |||||
using Discord.Net.WebSockets; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -151,7 +151,7 @@ namespace Discord.Net.Providers.WS4Net | |||||
} | } | ||||
private void OnBinaryMessage(object sender, DataReceivedEventArgs e) | private void OnBinaryMessage(object sender, DataReceivedEventArgs e) | ||||
{ | { | ||||
BinaryMessage(e.Data, 0, e.Data.Count()).GetAwaiter().GetResult(); | |||||
BinaryMessage(e.Data, 0, e.Data.Length).GetAwaiter().GetResult(); | |||||
} | } | ||||
private void OnConnected(object sender, object e) | private void OnConnected(object sender, object e) | ||||
{ | { | ||||
@@ -1,4 +1,3 @@ | |||||
using System; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -1,4 +1,3 @@ | |||||
using System; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -1,5 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
using System; | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -1,5 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
using System; | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -1,5 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
using System; | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -1,5 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
using System; | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -3,7 +3,6 @@ using Discord.Net.Converters; | |||||
using Discord.Net.Rest; | using Discord.Net.Rest; | ||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Globalization; | |||||
using System.IO; | using System.IO; | ||||
using System.Text; | using System.Text; | ||||
@@ -69,7 +69,6 @@ namespace Discord.Rest | |||||
/// Gets a message from this message channel. | /// Gets a message from this message channel. | ||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier of the message.</param> | /// <param name="id">The snowflake identifier of the message.</param> | ||||
/// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents an asynchronous get operation for retrieving the message. The task result contains | /// A task that represents an asynchronous get operation for retrieving the message. The task result contains | ||||
@@ -1,6 +1,5 @@ | |||||
#pragma warning disable CS1591 | #pragma warning disable CS1591 | ||||
using Discord.API.Gateway; | using Discord.API.Gateway; | ||||
using Discord.API.Rest; | |||||
using Discord.Net.Queue; | using Discord.Net.Queue; | ||||
using Discord.Net.Rest; | using Discord.Net.Rest; | ||||
using Discord.Net.WebSockets; | using Discord.Net.WebSockets; | ||||
@@ -3,7 +3,6 @@ using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.Diagnostics.CodeAnalysis; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -1,8 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using System; | |||||
using Microsoft.CodeAnalysis; | using Microsoft.CodeAnalysis; | ||||
using Microsoft.CodeAnalysis.Diagnostics; | using Microsoft.CodeAnalysis.Diagnostics; | ||||
using Discord.Analyzers; | using Discord.Analyzers; | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -7,7 +7,6 @@ using Microsoft.CodeAnalysis; | |||||
using Microsoft.CodeAnalysis.CSharp; | using Microsoft.CodeAnalysis.CSharp; | ||||
using Microsoft.CodeAnalysis.Diagnostics; | using Microsoft.CodeAnalysis.Diagnostics; | ||||
using Microsoft.CodeAnalysis.Text; | using Microsoft.CodeAnalysis.Text; | ||||
using Discord; | |||||
using Discord.Commands; | using Discord.Commands; | ||||
namespace TestHelper | namespace TestHelper | ||||
@@ -1,8 +1,7 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using Microsoft.CodeAnalysis; | using Microsoft.CodeAnalysis; | ||||
using Microsoft.CodeAnalysis.CSharp; | |||||
using Microsoft.CodeAnalysis.Diagnostics; | using Microsoft.CodeAnalysis.Diagnostics; | ||||
//using Microsoft.VisualStudio.TestTools.UnitTesting; | //using Microsoft.VisualStudio.TestTools.UnitTesting; | ||||
using Xunit; | using Xunit; | ||||
@@ -104,7 +103,7 @@ namespace TestHelper | |||||
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param> | /// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param> | ||||
private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults) | private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults) | ||||
{ | { | ||||
int expectedCount = expectedResults.Count(); | |||||
int expectedCount = expectedResults.Length; | |||||
int actualCount = actualResults.Count(); | int actualCount = actualResults.Count(); | ||||
if (expectedCount != actualCount) | if (expectedCount != actualCount) | ||||
@@ -9,7 +9,6 @@ using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.IO; | using System.IO; | ||||
using System.Linq; | |||||
using System.Net; | using System.Net; | ||||
using System.Reactive.Linq; | using System.Reactive.Linq; | ||||
using System.Reactive.Subjects; | using System.Reactive.Subjects; | ||||
@@ -142,4 +141,4 @@ namespace Discord.Net | |||||
return stream.WriteAsync(data, start, length).ToObservable(); | return stream.WriteAsync(data, start, length).ToObservable(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,5 +1,4 @@ | |||||
using Discord.Rest; | using Discord.Rest; | ||||
using System; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Xunit; | using Xunit; | ||||
@@ -171,15 +170,15 @@ namespace Discord | |||||
// 2 categories | // 2 categories | ||||
Assert.Equal(2, categories.Length); | Assert.Equal(2, categories.Length); | ||||
var cat1 = categories.Where(x => x.Name == "cat1").FirstOrDefault(); | |||||
var cat2 = categories.Where(x => x.Name == "cat2").FirstOrDefault(); | |||||
var cat1 = categories.FirstOrDefault(x => x.Name == "cat1"); | |||||
var cat2 = categories.FirstOrDefault(x => x.Name == "cat2"); | |||||
Assert.NotNull(cat1); | Assert.NotNull(cat1); | ||||
Assert.NotNull(cat2); | Assert.NotNull(cat2); | ||||
// get text1, text2, ensure they have category id == cat1 | // get text1, text2, ensure they have category id == cat1 | ||||
var text1 = allChannels.Where(x => x.Name == "text1").FirstOrDefault() as RestTextChannel; | |||||
var text2 = allChannels.Where(x => x.Name == "text2").FirstOrDefault() as RestTextChannel; | |||||
var text1 = allChannels.FirstOrDefault(x => x.Name == "text1") as RestTextChannel; | |||||
var text2 = allChannels.FirstOrDefault(x => x.Name == "text2") as RestTextChannel; | |||||
Assert.NotNull(text1); | Assert.NotNull(text1); | ||||
Assert.NotNull(text2); | Assert.NotNull(text2); | ||||
@@ -197,8 +196,8 @@ namespace Discord | |||||
Assert.Equal(text2Cat.Name, cat1.Name); | Assert.Equal(text2Cat.Name, cat1.Name); | ||||
// do the same for the voice channels | // do the same for the voice channels | ||||
var voice1 = allChannels.Where(x => x.Name == "voice1").FirstOrDefault() as RestVoiceChannel; | |||||
var voice3 = allChannels.Where(x => x.Name == "voice3").FirstOrDefault() as RestVoiceChannel; | |||||
var voice1 = allChannels.FirstOrDefault(x => x.Name == "voice1") as RestVoiceChannel; | |||||
var voice3 = allChannels.FirstOrDefault(x => x.Name == "voice3") as RestVoiceChannel; | |||||
Assert.NotNull(voice1); | Assert.NotNull(voice1); | ||||
Assert.NotNull(voice3); | Assert.NotNull(voice3); | ||||
@@ -1,4 +1,3 @@ | |||||
using System; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Xunit; | using Xunit; | ||||