Releases: Discord-Net-Labs/Discord.Net-Labs
v3.1.5
With the new implementation of checking the time of the interaction before responding - the issue is that this was using the interaction ids date component, discord likes to be hip and quirky and made the date as the time you start typing the command. this means if you take more than 3 seconds to type the command then it will fail.
This is been addressed in 3.1.5.
Full Changelog: 3.1.4...3.1.5
v3.1.4
What's Changed
- Fix assignment of UserMentions by @emillly-b in #233
- Fix CleanContent by @emillly-b in #231
- Fix SocketSlashCommandData access modifier. by @emillly-b in #237
- Added check for duplicate responses to interactions. by @quinchs in #236
- Added check for 3 second timeout to interactions. by @quinchs in #235
- Fix url validation for embed urls. by @quinchs in 9a7e925
New Contributors
- @Rozen4334 made their first contribution in #232
Full Changelog: 3.1.2...3.1.4
v3.1.2
3.1.2
Changes
- Add .NET 5 build.
- Added
Ephemeral
property toAttachment
. - Fixed channel name ratelimits being ignored + any other property specific ratelimits.
- Added
ChannelTypes
toApplicationCommandOption
and builders. - Simplified
FollowupWithFileAsync
to just take a file path. - Added event for
SocketAutocompleteInteraction
calledAutocompleteExecuted
. - Added
CleanContent
toIMessage
and implemented entities. - Added support for
discord://
protocol on buttons. - Added
Competing
status type. - Added
Icon
andGetIconUrl
to roles. - Added
Interaction
toIMessage
and implemented entities. - Fix different rest channels not deserializing properly.
- Renamed
Default
and Required toIsDefault
andIsRequired
inIApplicationCommandOption
. - Renamed
DefaultPermission
toIsDefaultPermission
inIApplicationCommand
. - Refactored some summaries
- Renamed
Available
toIsAvailable
in stickers. - Fix NRE in modify guild channel.
- Removed file extension check.
- Fixed system messages not including mentioned users.
- Added
ContextMenuCommand
message type. - Added stage instance audit logs as well as thread audit log type.
- Remove null collections in favor for empty collections.
- Fixed sub commands being interpreted as a parameter for autocomplete.
- Fixed
Type
not being set inSocketApplicationCommand
. - Added restriction for description not being null in
SlashCommandBuilder
.
New Contributors
- @drobbins329 made their first contribution in #86
- @CottageDwellingCat made their first contribution in #128
- @IllidanS4 made their first contribution in #137
- @louistio made their first contribution in #136
- @MysticalSoul made their first contribution in #161
- @WilliamWelsh made their first contribution in #198
- @envyvox made their first contribution in #206
- @emillly-b made their first contribution in #174
- @marens101 made their first contribution in #214
Version 3.0 Release
Release 3.0
Nuget links:
Hello! I'm happy to announce version 3.0! This update contains a lot of fixes, new features, and improvements to the library! Here's some of the major additions:
- Thread support (THREAD ITTTT!!!!)
- Stage support (Stage it up!)
- Context menu commands (Right click commands)
- Full sticker support!
- Events for different interactions!
Threads
Threads are here! With labs its pretty simple to use and quite effective! Both Rest support and socket support is implemented.
Creating a thread
Creating a thread is simple. You can create a thread within a text channel
Websocket:
var textChannel = client.GetGuild(guildId).GetTextChannel(channelId);
var thread = await textChannel.CreateThreadAsync("My thread!");
Rest:
var guild = await arg.Rest.GetGuildAsync(guildId);
var textChannel = await guild.GetTextChannelAsync(channelId);
var thread = await textChannel.CreateThreadAsync("Hello from rest!");
Adding users to threads
await thread.AddUserAsync(guildUser);
Removing users from threads
await thread.RemoveUserAsync(guildUser);
Modifying a thread
You can change the name, archived status, archive duration, and locked status of a thread using its ModifyAsync
method.
await thread.ModifyAsync(x => {
x.Name = "My new thread name",
x.Archived = false,
x.Locked = false,
x.AutoArchiveDuration = ThreadArchiveDuration.OneHour
});
Note: the standard text channel properties are included within the modify async action but are ignored.
Websocket events
ThreadCreated
- Fired when a thread is created within a guild, or when the current user is added to a thread.ThreadUpdated
- Fired when a thread is updated.ThreadDeleted
- Fired when a thread is deleted.ThreadMemberJoined
- Fired when a user joins a thread.ThreadMemberLeft
- Fired when a user leaves a thread.
Stages
Stage channel support has been fully implemented into labs. Discord is rolling out new stage stuff like queuing so I'm sure this will be a thing added to the lib in the future.
Getting a stage channel
Websocket:
var stage = client.GetGuild(guildId).GetStageChannel(channelId);
Rest:
var guild = await arg.Rest.GetGuildAsync(guildId);
var stage = await guild.GetStageChannelAsync(channelId);
Starting, stopping and modifying a stage
await stage.StartStageAsync("your topic", StagePrivacyLevel.Public);
// Modifying the instance of the stage is how you would change the running stages topic and privacy level, there is still ModifyAsync that will modify the channel properties.
await stage.ModifyInstanceAsync(x =>
{
x.PrivacyLevel = StagePrivacyLevel.GuildOnly;
x.Topic = "new topic";
});
await stage.StopStageAsync();
Requesting to speak within a stage
await stage.RequestToSpeakAsync();
Become a speaker
await stage.BecomeSpeakerAsync();
Stop speaking
await stage.StopSpeakingAsync();
Make user speaker
var user = stage.GetUser(userId);
await stage.MoveToSpeakerAsync(user);
Removing a speaker
var user = stage.GetUser(userId);
await stage.RemoveFromSpeakerAsync(user);
Websocket events
StageCreated
- Fired when a stage starts.StageUpdated
- Fired when a stage is updated.StageEnded
- Fired when a stage ends.RequestToSpeak
- Fired when a user requests to speak in a stage.SpeakerAdded
- Fired when a user becomes a speaker in a stage.SpeakerRemoved
- Fired when a speaker is removed from a stage.
Context Menu Commands
Labs now supports context menu commands! This is a new feature that allows you to create commands that are triggered by right clicking on a message or user.
Documentation for these special commands can be found here.
Full Sticker support
Labs now has full sticker support, including creating, modifying, and deleting stickers.
Types (Websocket)
There are 3 types of websocket stickers:
SocketSticker
├─SocketCustomSticker
└─SocketUnknownSticker
SocketSticker
is the base class for all stickers, it contains the basic infromation about the sticker.SocketCustomSticker
is a subclass ofSocketSticker
that represents a custom sticker within a guild.SocketUnknownSticker
is a subclass ofSocketSticker
that represents a sticker that couldn't be resolved.
SocketSticker
Name | Type | Description |
---|---|---|
Id | ulong | Gets the ID of this sticker. |
PackId | ulong | Gets the ID of the pack of this sticker. |
Name | string | Gets the name of this sticker. |
Description | string | Gets the description of this sticker. |
Tags | IReadOnlyCollection | Gets the list of tags of this sticker. |
Asset | string | Gets the asset hash of this sticker. |
PreviewAsset | string | Gets the preview asset hash of this sticker. |
Format | StickerFormatType | Gets the format type of this sticker. |
Methods
Name | Return type | Description |
---|---|---|
GetStickerUrl | string | Gets the image url for this sticker. |
SocketCustomSticker
All properties and functions are inherited from SocketSticker
.
Name | Type | Description |
---|---|---|
Author | SocketGuildUser | Gets the user that uploaded the guild sticker. |
Guild | SocketGuild | Gets the guild the sticker lives in. |
Methods
Name | Return type | Description |
---|---|---|
ModifyAsync | Task | Modifies this sticker. |
DeleteAsync | Task | Deletes the current sticker. |
Resolving an Unknown Sticker
SocketUnknownSticker
has a function called ResolveAsync
that will attempt to resolve the sticker via the REST-API. An example of a unknown sticker is a sticker that is from a guild that the bot isn't in, these stickers are resolvable with the ResolveAsync
Getting a sticker
You can do a full seach for a sticker with a provided id by using
var sticker = client.GetSticker(stickerId);
This will look inside the cache of all stickers (guild and nitro) for the sticker with the provided id, if you want to to an extended seach by making use of the RESTFUL api, you can use:
var sticker = await client.GetStickerAsync(stickerId);
Creating a sticker
var guild = client.GetGuild(guildId);
var sticker = await guild.CreateStickerAsync("mike", "Good ol' mike!", new string[] {"mike", "mikey"}, "mike.png");
Websocket events
GuildStickerCreated
- Fired when a sticker in a guild is created.GuildStickerUpdated
- Fired when a sticker in a guild is updated.GuildStickerDeleted
- Fired when a sticker in a guild is deleted.
Interaction events expanded
Due to popular demand, Labs now has an event for each interaction type:
ButtonExecuted
- Fired when a button is clicked and its interaction is received.SelectMenuExecuted
- Fired when a select menu is used and its interaction is received.SlashCommandExecuted
- Fired when a slash command is used and its interaction is received.UserCommandExecuted
- Fired when a user command is used and its interaction is received.MessageCommandExecuted
- Fired when a message command is used and its interaction is received.
Note: The InteractionCreated
event is still used and fired for backwards compatibility.
Changelog
- Added stage support.
- Added multi embed support for normal messages and refactored methods for interaction with embeds.
- Added check for proper urls in embeds and buttons.
- Made custom id an optional parameter in buttons.
- Fixed respond async fallback not taking in components.
- Added thread support.
- Added
NsfwLevel
property to guilds. - Fixed Emoji UnicodeAndNames throwing exception because of duplicit keys.
- Added missing message types: GuildDiscoveryDisqualified, GuildDiscoveryRequalified, GuildDiscoveryGracePeriodInitialWarning, GuildDiscoveryGracePeriodFinalWarning, ThreadCreated, ThreadStarterMessage, and GuildInviteReminder.
- Added
NUMBER
application command option type. - Refactored the component builders to be more flexible.
- Changed
AcknowledgeAsync
toDeferAsync
to avoid confusion. - Fixed
PermissionTarget
andApplicationCommandPermissionTarget
confusion and Invalid Form ...
Pre release of version 3
Pre release 3.0
Nuget links:
Hello! I'm happy to announce a pre release version 3.0.0! This update contains a lot of fixes, new features, and improvements to the library!
Contributors
I'd like to thank these people for contributing to the labs project!
- @Rutherther - 4610dd1
- @INikonl - a6154fd, 8eda677, 1803221, 8433476
- @Zeiin - a1a498d, 501276c, 014dd9f
- @MrCakeSlayer - 91496b8, b01c298
Threads
Threads are here! With labs its pretty simple to use and quite effective! Both Rest support and socket support is implemented.
Creating a thread
Creating a thread is simple. You can create a thread within a
Websocket:
var textChannel = client.GetGuild(guildId).GetTextChannel(channelId);
var thread = await textChannel.CreateThreadAsync("My thread!");
Rest:
var guild = await arg.Rest.GetGuildAsync(guildId);
var textChannel = await guild.GetTextChannelAsync(channelId);
var thread = await textChannel.CreateThreadAsync("Hello from rest!");
Adding users to threads
await thread.AddUserAsync(guildUser);
Removing users from threads
await thread.RemoveUserAsync(guildUser);
Modifying a thread
You can change the name, archived status, archive duration, and locked status of a thread using its ModifyAsync
method.
await thread.ModifyAsync(x => {
x.Name = "My new thread name",
x.Archived = false,
x.Locked = false,
x.AutoArchiveDuration = ThreadArchiveDuration.OneHour
});
Note: the standard text channel properties are included within the modify async action but are ignored.
Websocket events
ThreadCreated
- Fired when a thread is created within a guild, or when the current user is added to a thread.ThreadUpdated
- Fired when a thread is updated.ThreadDeleted
- Fired when a thread is deleted.ThreadMemberJoined
- Fired when a user joins a thread.ThreadMemberLeft
- Fired when a user leaves a thread.
Stages
Stage channel support has been fully implemented into labs. Discord is rolling out new stage stuff like queuing so I'm sure this will be a thing added to the lib in the future.
Getting a stage channel
Websocket:
var stage = client.GetGuild(guildId).GetStageChannel(channelId);
Rest:
var guild = await arg.Rest.GetGuildAsync(guildId);
var stage = await guild.GetStageChannelAsync(channelId);
Starting, stopping and modifying a stage
await stage.StartStageAsync("your topic", StagePrivacyLevel.Public);
// Modifying the instance of the stage is how you would change the running stages topic and privacy level, there is still ModifyAsync that will modify the channel properties.
await stage.ModifyInstanceAsync(x =>
{
x.PrivacyLevel = StagePrivacyLevel.GuildOnly;
x.Topic = "new topic";
});
await stage.StopStageAsync();
Requesting to speak within a stage
stage.RequestToSpeak();
Websocket events
StageCreated
- Fired when a stage starts.StageUpdated
- Fired when a stage is updated.StageEnded
- Fired when a stage ends.RequestToSpeak
- Fired when a user requests to speak in a stage.SpeakerAdded
- Fired when a user becomes a speaker in a stage.SpeakerRemoved
- Fired when a speaker is removed from a stage.
Changelog
- Added stage support.
- Added multi embed support for normal messages and refactored methods for interaction with embeds.
- Added check for proper urls in embeds and buttons.
- Made custom id an optional parameter in buttons.
- Fixed respond async fallback not taking in components.
- Added thread support.
- Added
NsfwLevel
property to guilds. - Fixed Emoji UnicodeAndNames throwing exception because of duplicit keys.
- Added missing message types: GuildDiscoveryDisqualified, GuildDiscoveryRequalified, GuildDiscoveryGracePeriodInitialWarning, GuildDiscoveryGracePeriodFinalWarning, ThreadCreated, ThreadStarterMessage, and GuildInviteReminder.
- Added
NUMBER
application command option type. - Refactored the component builders to be more flexible.
- Changed
AcknowledgeAsync
toDeferAsync
to avoid confusion. - Fixed
PermissionTarget
andApplicationCommandPermissionTarget
confusion and Invalid Form Body for modifying channel overwrites. - Added missing audit log types: IntegrationCreated,IntegrationUpdated, IntegrationDeleted, StageInstanceCreated, StageInstanceUpdated, StageInstanceDeleted, StickerCreated, StickerUpdated, and StickerUpdated.
- Updated
MaxOptionsCount
andMaxChoiceCount
to 25.