Adding Entity guides, flowcharts, better sample system. (#2054)

* initial

* Interaction glossary entry

* Sharded Interaction sample

* Renames into solution

* Debugging samples

* Modify target location for webhookclient

* Finalizing docs work, resolving docfx errors.

* Adding threaduser to user chart

* Add branch info to readme.

* Edits to user chart

* Resolve format for glossary entries

* Patch sln target

* Issue with file naming fixed

* Patch 1/x for builds

* Appending suggestions
This commit is contained in:
Armano den Boef
2022-01-27 14:50:49 +01:00
committed by GitHub
parent b0f59e3eb9
commit b14af1c008
57 changed files with 1059 additions and 344 deletions

View File

@@ -1,6 +1,6 @@
using JetBrains.Annotations;
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Discord.Net.Examples.Core.Entities.Channels
{
@@ -11,8 +11,10 @@ namespace Discord.Net.Examples.Core.Entities.Channels
public async Task MuteRoleAsync(IRole role, IGuildChannel channel)
{
if (role == null) throw new ArgumentNullException(nameof(role));
if (channel == null) throw new ArgumentNullException(nameof(channel));
if (role == null)
throw new ArgumentNullException(nameof(role));
if (channel == null)
throw new ArgumentNullException(nameof(channel));
// Fetches the previous overwrite and bail if one is found
var previousOverwrite = channel.GetPermissionOverwrite(role);
@@ -29,8 +31,10 @@ namespace Discord.Net.Examples.Core.Entities.Channels
public async Task MuteUserAsync(IGuildUser user, IGuildChannel channel)
{
if (user == null) throw new ArgumentNullException(nameof(user));
if (channel == null) throw new ArgumentNullException(nameof(channel));
if (user == null)
throw new ArgumentNullException(nameof(user));
if (channel == null)
throw new ArgumentNullException(nameof(channel));
// Fetches the previous overwrite and bail if one is found
var previousOverwrite = channel.GetPermissionOverwrite(user);

View File

@@ -1,8 +1,8 @@
using JetBrains.Annotations;
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Discord.Net.Examples.Core.Entities.Channels
{
@@ -90,7 +90,7 @@ namespace Discord.Net.Examples.Core.Entities.Channels
#region SendFileAsync.FilePath.EmbeddedImage
await channel.SendFileAsync("b1nzy.jpg",
embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
embed: new EmbedBuilder { ImageUrl = "attachment://b1nzy.jpg" }.Build());
#endregion
@@ -99,13 +99,14 @@ namespace Discord.Net.Examples.Core.Entities.Channels
using (var b1nzyStream = await httpClient.GetStreamAsync("https://example.com/b1nzy"))
await channel.SendFileAsync(b1nzyStream, "b1nzy.jpg",
embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
embed: new EmbedBuilder { ImageUrl = "attachment://b1nzy.jpg" }.Build());
#endregion
#region EnterTypingState
using (channel.EnterTypingState()) await LongRunningAsync();
using (channel.EnterTypingState())
await LongRunningAsync();
#endregion
}

View File

@@ -1,7 +1,7 @@
using JetBrains.Annotations;
using System;
using System.Net;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Discord.Net.Examples.Core.Entities.Users
{

View File

@@ -1,8 +1,8 @@
using Discord.WebSocket;
using JetBrains.Annotations;
using System;
using System.Linq;
using System.Threading.Tasks;
using Discord.WebSocket;
using JetBrains.Annotations;
namespace Discord.Net.Examples.WebSocket
{
@@ -74,7 +74,7 @@ namespace Discord.Net.Examples.WebSocket
#region MessageReceived
private readonly ulong[] _targetUserIds = {168693960628371456, 53905483156684800};
private readonly ulong[] _targetUserIds = { 168693960628371456, 53905483156684800 };
public void HookMessageReceived(BaseSocketClient client)
=> client.MessageReceived += HandleMessageReceived;
@@ -82,9 +82,11 @@ namespace Discord.Net.Examples.WebSocket
public Task HandleMessageReceived(SocketMessage message)
{
// check if the message is a user message as opposed to a system message (e.g. Clyde, pins, etc.)
if (!(message is SocketUserMessage userMessage)) return Task.CompletedTask;
if (!(message is SocketUserMessage userMessage))
return Task.CompletedTask;
// check if the message origin is a guild message channel
if (!(userMessage.Channel is SocketTextChannel textChannel)) return Task.CompletedTask;
if (!(userMessage.Channel is SocketTextChannel textChannel))
return Task.CompletedTask;
// check if the target user was mentioned
var targetUsers = userMessage.MentionedUsers.Where(x => _targetUserIds.Contains(x.Id));
foreach (var targetUser in targetUsers)
@@ -103,7 +105,8 @@ namespace Discord.Net.Examples.WebSocket
public async Task HandleMessageDelete(Cacheable<IMessage, ulong> cachedMessage, Cacheable<IMessageChannel, ulong> cachedChannel)
{
// check if the message exists in cache; if not, we cannot report what was removed
if (!cachedMessage.HasValue) return;
if (!cachedMessage.HasValue)
return;
// gets or downloads the channel if it's not in the cache
IMessageChannel channel = await cachedChannel.GetOrDownloadAsync();
var message = cachedMessage.Value;