Discord.Addons.Linking 1.0.0

dotnet add package Discord.Addons.Linking --version 1.0.0
NuGet\Install-Package Discord.Addons.Linking -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Discord.Addons.Linking" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Discord.Addons.Linking --version 1.0.0
#r "nuget: Discord.Addons.Linking, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Discord.Addons.Linking as a Cake Addin
#addin nuget:?package=Discord.Addons.Linking&version=1.0.0

// Install Discord.Addons.Linking as a Cake Tool
#tool nuget:?package=Discord.Addons.Linking&version=1.0.0

Discord.Addons.Linking

An extension for Discord.Net that adds linkable messages.

Purpose

This extension was made primarily to enable the synchronization of multiple messages with the exact same content at once. This allows you to update a single parent message, which will then automatically update all linked children.

Additions

LinkedMessage

The LinkedMessage binds to messages that are not sent by the bot, and are instantly updated whenever that message is updated.

LinkedUserMessage

The LinkedUserMessage binds to a message that was only sent from a bot, and can be manually modified at any point in time. Keep in mind that a LinkedUserMessage inherits the LinkedMessage class, which means that all methods that the LinkedMessage class contains can also be executed by a LinkedUserMessage.

Methods

Initializing a LinkedMessage

LinkedMessage linkedMessage = LinkedMessage.Create(Context.Message, LinkDeleteHandling.Source, Context.Client);

The parameters for the LinkedMessage structure requires an IMessage to bind to, a specified LinkDeleteHandling flag, and a BaseSocketClient to initialize this message for. The BaseSocketClient is used to automatically handle updates when the message is changed.

Initializing a LinkedUserMessage

RestUserMessage message = await Context.Channel.SendMessageAsync("This is a test.");
LinkedUserMessage linkedUserMessage = LinkedUserMessage.Create(message, LinkDeleteHandling.Source);

The parameters for the LinkedUserMessage requires an IUserMessage to bind to, along with a specified LinkDeleteHandling flag. Although a BaseSocketClient isn't required to initialize a new LinkedUserMessage, it will not be able to automatically handle source deletion outside of the program. An example of this is when a user manually deletes the message from Discord.

Updating a LinkedUserMessage

await linkedUserMessage.ModifyAsync(x => x.Content = "This is an updated message.");

This method is identical to the existing ModifyAsync methods that exist on Discord message classes. Using this will update all subscribed children from this method.

Creating a child for a LinkedMessage

IUserMessage child = await linkedMessage.CloneAsync(Context.Channel);

This method initializes a new message to the specified IChannel that will automatically update whenever the parent message is updated. Likewise with other Discord methods, there is an optional parameter for RequestOptions. This method can be called multiple times in the same channel, but it will simply just initialize new children messages.

Binding messages to a LinkedMessage

RestUserMessage newChild = await Context.Channel.SendMessageAsync("This is a message.");
bool isLinkSuccess = await linkedMessage.AddAsync(newChild);

As long as the binding message is an IUserMessage, the message can be linked to a LinkedMessage. This will automatically update the binding message to mimic the parent message as well, only if the method was successful.

Unbinding children messages from a LinkedMessage

bool isSuccess = linkedMessage.Remove(messageId);

When this method is called, it will attempt to remove and unlink the specified message ID (ulong) from the collection of children. If it was successful, it will return a Boolean value as true. Otherwise, it will return false.

Deleting a LinkedMessage

await linkedMessage.DeleteAsync();

This method will delete a LinkedMessage. The way a LinkedMessage is deleted is entirely based on the LinkDeleteHandling flag you set. If the specified flag is LinkDeleteHandling.All, every message that the LinkedMessage handles is deleted. This includes all children alongside the parent. Likewise, if the specified flag is LinkDeleteHandling.Source, all children within a LinkedMessage will be updated to display [Original Message Deleted], while the source of the LinkedMessage is deleted.

Credits

Discord.Net for the original logo design.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 657 4/1/2020