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 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. - Added Sticker support
- Fixed content type not being specified for file uploads.
- Fixed
CurrentUserId
in sharded client being null. - Added multiple events for interactions.
- Added url restrictions for button urls and embed urls.
- Reworked how interactions are handled in websocket.