Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Docs rework, prep for merge into DNET #359

Merged
merged 19 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,165 @@
# Changelog

## [3.4.9] - 12/06/2021

### Fixed

- NRE when responding to an interaction with just an embed

## [3.4.8] - 12/04/2021

### Added

- Check for creating threads in news channels.
- Back netstandard2.0 and netstandard2.1 builds.
- IApplicationCommandInteraction interface and make IUserCommandInteraction, IMessageCommandInteraction, and ISlashCommandInteraction inherit it.
- FollowupWithFilesAsync to interactions to allow uploading multiple attachments.
- IUser User to IDiscordInteraction.

### Fixed

- NRE on modifying messages allowed mentions again.

### Misc

- Deprecate ApplicationCommandException in favor for HttpException.
- Made RespondAsync return a RestInteractionMessage based off of the parameters sent over to discord. This allows direct calls to ModifyAsync and DeleteAsync without having to get the interaction response first.
- Change Followup / Respond method signatures to move RequestOptions to the last parameter as well as change component to components.
- Update async summaries to contain information about the task in the return tag.

## [3.4.7] - 28/11/2021

### Added

- Methods for manually registering global comands.

### Fixed

- NRE on service providerless command execution.
- Wrong link in interactions framework docs.

## [3.4.6] - 27/11/2021

### Fixed

- Self user presence throwing upon set.

## [3.4.5] - 27/11/2021

### Fixed

- Another NRE with presence.

## [3.4.4] - 27/11/2021

### Fixed

- NRE with presence causing guild members to basically not exist.

## [3.4.3] - 27/11/2021

### Added

- PresenceUpdate socket event to help alleviate GuildMemberUpdate event calls.
- Guild.ClearUserCache(Predicate) to socket guilds.
- Warnings to the gateway client about intents, you can disable them by setting LogGatewayIntentWarnings to false in the discord socket config.
- DefaultApplications enum with the default games in the discord games lab.
- Support for sending multiple files on Webhooks.
- MaxBitrate to the IGuild interface.

### Fixed

- Bi-directional unicode names getting formatted wrong when calling IUser.ToString().
- CurrentUser with ICommandContext on DiscordShardedClient being null.
- NRE on Emote.TryParse.

## [3.4.2] - 26/11/2021

### Fixed

- Improve the GuildFeatures converter.
- Message/User commands are not being executed when their name have spaces on it.

## [3.4.1] - 26/11/2021

### Fixed

- SocketVoiceChannel options are created as generic mentionables in Interaction service

## [3.4.0] - 26/11/2021

### Added

- Interaction Service framework.

### Fixed

- NRE when modifying allowed mentions.

### Misc

- Updated summaries of interaction related classes.

## [3.3.3] - 11/23/2021

### Added

- Emoji to roles
- Invitable and Slowmode to thread creation
- Better discord errors.
- UseInteractionSnowflakeDate to config.

### Fixed

- Components not showing on FollowUpWithFile.
- Change the minimum length of slash commands to 1.
- Ratelimit timings.

### Misc

- Make RestUserCommand public.

## [3.3.2] - 11/21/2021

### Added

- GuildScheduledEventUserAdd and GuildScheduledEventUserRemove.
- New Cacheable<> type for rest based downloads while maintaining strong typed entities.

### Fixed

- Autocomplete not accepting values

## [3.3.1] - 11/21/2021

### Added

- ConfigureAwait(false) to async calls in rest based interactions.

### Fixed

- Slash commands will now have populated data.

## [3.3.0] - 11/19/2021

### Added

- Guild events.
- Rest-based http interactions.
- RTCRegion to voice channel properties.
- Support Min and Max values on ApplicationCommandOptions.
- Automatically fix ordering of optional command options.
- Interaction Specific Interfaces.

### Fixed

- Maximum number of Select Menu Options.

### Misc

- Changed default sticker behavior. You can configure getting default stickers on startup and auto resolve stickers with AlwaysDownloadDefaultStickers and AlwaysResolveStickers.
- Logomark, doc settings edit.

## [3.2.0] - 11/09/2021

### Added
Expand Down
50 changes: 0 additions & 50 deletions FAQ.md

This file was deleted.

29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,6 @@ Setting up labs in your project is really simple, here's how to do it:
2) Add Discord.Net Labs nuget to your project
3) That's all!

## Implementations
What Discord.NET-labs has that Discord.NET does not:

- Major changes
* Interaction Support.
* Application commands (slash, user, message).
* Message Components (buttons, select menus).
* Thread Channels.
* Stage Channels.
* Guild Events.
* Revamped Stickers.

- Minor changes
* Added `TimestampTag`.
* Made `Hierarchy` a `IGuildUser` property.
* Changes embed discription length to 4096.
* Added `Name` property to teams.
* Added url validation to embeds.
* Added `NsfwLevel` to Guilds.
* Added helpers to `Emoji` for parsing.
* Fixed gateway serialization to include nulls.
* Added banner and accent color to guild users.
* Fixed `CurrentUserId` in sharded clients being null.
* Fixed Guild owner and Admin `GuildPermissions.All`.
* Added `RatelimitCallback` to `RequestOptions`.

## Branches

### Dev
Expand All @@ -84,8 +58,5 @@ This branch is kept up to date with dnets dev branch. we pull of it to ensure th
### release/3.x
This branch is what will be pushed to nuget, sometimes its not up to date as we wait for other features to be finished.

### old/SlashCommandService
This branch is on pause and does not work currently, There is a pull request open to implement a working version of a slash command service. It can be found [here](https://github.com/Discord-Net-Labs/Discord.Net-Labs/pull/52)

### feature/xyz
These branches are features for new things, you are more than welcome to clone them and give feedback in the discord server or issues tab.
123 changes: 123 additions & 0 deletions docs/faq/basics/basic-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
uid: FAQ.Basics.BasicOp
title: Questions about Basic Operations
---

# Basic Operations Questions

In the following section, you will find commonly asked questions and
answers regarding basic usage of the library, as well as
language-specific tips when using this library.

## How should I safely check a type?

> [!WARNING]
> Direct casting (e.g., `(Type)type`) is **the least recommended**
> way of casting, as it *can* throw an [InvalidCastException]
> when the object isn't the desired type.
>
> Please refer to [this post] for more details.

In Discord.Net, the idea of polymorphism is used throughout. You may
need to cast the object as a certain type before you can perform any
action.

A good and safe casting example:

[!code-csharp[Casting](samples/cast.cs)]

[InvalidCastException]: https://docs.microsoft.com/en-us/dotnet/api/system.invalidcastexception
[this post]: https://docs.microsoft.com/en-us/dotnet/csharp/how-to/safely-cast-using-pattern-matching-is-and-as-operators

## How do I send a message?

> [!TIP]
> The [GetChannel] method by default returns an [IChannel], allowing
> channel types such as [IVoiceChannel], [ICategoryChannel]
> to be returned; consequently, you cannot send a message
> to channels like those.

Any implementation of [IMessageChannel] has a [SendMessageAsync]
method. You can get the channel via [GetChannel] under the client.
Remember, when using Discord.Net, polymorphism is a common recurring
theme. This means an object may take in many shapes or form, which
means casting is your friend. You should attempt to cast the channel
as an [IMessageChannel] or any other entity that implements it to be
able to message.

[SendMessageAsync]: xref:Discord.IMessageChannel.SendMessageAsync*
[GetChannel]: xref:Discord.WebSocket.DiscordSocketClient.GetChannel*

## How can I tell if a message is from X, Y, Z channel?

You may check the message channel type. Visit [Glossary] to see the
various types of channels.

[Glossary]: xref:FAQ.Glossary#message-channels

## How can I get the guild from a message?

There are 2 ways to do this. You can do either of the following,

1. Cast the user as an [IGuildUser] and use its [IGuild] property.
2. Cast the channel as an [IGuildChannel] and use its [IGuild] property.

## How do I add hyperlink text to an embed?

Embeds can use standard [markdown] in the description field as well
as in field values. With that in mind, links can be added with
`[text](link)`.

[markdown]: https://support.discordapp.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-

## How do I add reactions to a message?

Any entity that implements [IUserMessage] has an [AddReactionAsync]
method. This method expects an [IEmote] as a parameter.
In Discord.Net, an Emote represents a custom-image emote, while an
Emoji is a Unicode emoji (standard emoji). Both [Emoji] and [Emote]
implement [IEmote] and are valid options.

# [Adding a reaction to another message](#tab/emoji-others)

[!code-csharp[Emoji](samples/emoji-others.cs)]

# [Adding a reaction to a sent message](#tab/emoji-self)

[!code-csharp[Emoji](samples/emoji-self.cs)]

***

[AddReactionAsync]: xref:Discord.IMessage.AddReactionAsync*

## What is a "preemptive rate limit?"

A preemptive rate limit is Discord.Net's way of telling you to slow
down before you get hit by the real rate limit. Hitting a real rate
limit might prevent your entire client from sending any requests for
a period of time. This is calculated based on the HTTP header
returned by a Discord response.

## Why am I getting so many preemptive rate limits when I try to add more than one reactions?

This is due to how HTML header works, mistreating
0.25sec/action to 1sec. This causes the lib to throw preemptive rate
limit more frequently than it should for methods such as adding
reactions.

## Can I opt-out of preemptive rate limits?

Unfortunately, not at the moment. See [#401](https://github.com/RogueException/Discord.Net/issues/401).
csmir marked this conversation as resolved.
Show resolved Hide resolved

[IChannel]: xref:Discord.IChannel
[ICategoryChannel]: xref:Discord.ICategoryChannel
[IGuildChannel]: xref:Discord.IGuildChannel
[ITextChannel]: xref:Discord.ITextChannel
[IGuild]: xref:Discord.IGuild
[IVoiceChannel]: xref:Discord.IVoiceChannel
[IGuildUser]: xref:Discord.IGuildUser
[IMessageChannel]: xref:Discord.IMessageChannel
[IUserMessage]: xref:Discord.IUserMessage
[IEmote]: xref:Discord.IEmote
[Emote]: xref:Discord.Emote
[Emoji]: xref:Discord.Emoji
Loading