Skip to content

Commit

Permalink
Merge branch 'dev' into feature/member-search-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 committed Jun 30, 2024
2 parents 31a1977 + 28d3dcd commit 48b0d9a
Show file tree
Hide file tree
Showing 60 changed files with 4,122 additions and 1,828 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [3.15.1] - 2024-06-18
### Added
- #2927 Add missing PollProperties (a59f4ba)
- #2942 Add purchase notification (9d92435)
- #2934 Add MessageCallData (21195a8)
- #2932 Config Bypass for CanSendResponse (9030a5b)
- #2933 Premium Buttons (531b5eb)
- #2941 Add UseExternalApps permission (f7f29d5)
### Misc
- #2936 Public constructor for Emote (3be72a8)
- #2935 Generic autocomplete (35b102a)
- #2929 Enable nuget debug symbols. (aa424f6)

## [3.15.0] - 2024-05-12
### Added
- #2902 Polls (476ec06)
Expand Down
2 changes: 1 addition & 1 deletion Discord.Net.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>3.15.0</VersionPrefix>
<VersionPrefix>3.15.1</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Discord.Net Contributors</Authors>
<PackageTags>discord;discordapp</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"globalMetadata": {
"_appTitle": "Discord.Net Documentation",
"_appName": "Discord.Net",
"_appFooter": "Discord.Net © 2015-2024 3.15.0",
"_appFooter": "Discord.Net © 2015-2024 3.15.1",
"_enableSearch": true,
"_appLogoPath": "marketing/logo/SVG/Logomark Purple.svg",
"_appFaviconPath": "favicon.png"
Expand Down
8 changes: 8 additions & 0 deletions docs/faq/basics/channel-inheritance-tree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
uid: FAQ.Basics.ChannelInheritance
title: Channel Inheritance
---

# Discord.NET channel inheritance tree

![`IChannel` interface inheritance tree](images/channel-interface-tree.svg)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
353 changes: 353 additions & 0 deletions docs/faq/basics/images/channel-interface-tree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
528 changes: 528 additions & 0 deletions docs/faq/int_framework/images/response-scheme-component.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
526 changes: 526 additions & 0 deletions docs/faq/int_framework/images/response-scheme-modal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
429 changes: 429 additions & 0 deletions docs/faq/int_framework/images/response-scheme-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/faq/int_framework/respondings-schemes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Slash command interactions support the most commonly used response methods.
> [!NOTE]
> Same scheme applies to context command interactions.
![Slash command interaction](images/response-scheme-slash.png)
![Slash command interaction](images/response-scheme-slash.svg)

## Responding to a component interaction

Component interactions share a lot of response mwthods with [slash command interactions](#responding-to-a-slash-command-interaction), but they also provide a way to update the message components were attached to.
Component interactions share a lot of response methods with [slash command interactions](#responding-to-a-slash-command-interaction), but they also provide a way to update the message components were attached to.

> [!NOTE]
> Some followup methods change their behavior depending on what initial response you've sent.
![Slash command interaction](images/response-scheme-component.png)
![Component interaction](images/response-scheme-component.svg)

## Responding to a modal interaction

While being similar to [Component Interaction Scheme](#responding-to-a-modal-interaction), modal interactions lack the option of responding with a modal.

![Slash command interaction](images/response-scheme-modal.png)
![Modal interaction](images/response-scheme-modal.svg)
2 changes: 2 additions & 0 deletions docs/faq/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
topicUid: FAQ.Basics.ClientBasics
- name: Dependency Injection
topicUid: FAQ.Basics.DI
- name: Channel Inheritance
topicUid: FAQ.Basics.ChannelInheritance
- name: Interactions
items:
- name: Starting out
Expand Down
Binary file added docs/guides/polls/images/poll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions docs/guides/polls/polls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
uid: Guides.Polls
title: Polls
---

# Polls in Discord.Net

Polls are... Polls!

![example poll](images/poll.png)

This guide will explain how to use polls in your applications.

> [!NOTE]
> To get contents of polls sent by users other than your bot you need to enable `GatewayIntent.MessageContent` intent.
## Creating polls

A poll is part of a message; to send one you need to pass a [PollProperties] object into the `poll` parameter of any method that can be used to send messages. (ex. `SendMessageAsync`, `RespondAsync`, etc)

[!code-csharp[Creating polls](samples/create-poll.cs)]

> [!WARNING]
> Due to limitations of the Discord API it's not possible to send attachments in a messages with a poll.
> [!NOTE]
> It is not possible to modify polls after them being created.

## Managing polls

### Ending polls
You can expire polls early by calling `EndPollAsync` on an [IUserMessage] with a poll.

[!code-csharp[Ending polls](samples/end-poll.cs)]

### Getting poll answer voters
To get voters for a specific answer call `GetPollAnswerVotersAsync(answerId)` on an [IUserMessage] with a poll.

[!code-csharp[Getting poll answer voters](samples/get-poll-voters.cs)]

### Retrieving poll results
You can get results of a poll by simply getting an [IUserMessage] and checking the `IUserMessage.Poll.Results` property. Alteratively you can check the results on a `MessageUpdated` gateway event.


## Gateway events

### Poll votes
You can receive information about poll votes live using following events:
- `PollVoteAdded`
- `PollVoteRemoved`

> [!NOTE]
> These events are only sent if the client has `GatewayIntents.GuildMessagePolls` or `GatewayIntents.DirectMessagePolls` intents enabled. It will receive events for polls in guild or dm channels respectively.
### Poll expiry
On poll expiry the `MessageUpdated` event is fired.


[PollProperties]: xref:Discord.PollProperties
[IUserMessage]: xref:Discord.IUserMessage
40 changes: 40 additions & 0 deletions docs/guides/polls/samples/create-poll.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

// Create a poll
var poll = new PollProperties
{
// Set the question
Question = new ()
{ // Text of the question
Text = "Discord.Net is awesome!"
},
// Set the duration of the poll in hours
Duration = 69,
// Add answers to the poll
// You can add from 1 to 10 answers
Answers = [
// An answer can consist of text and an emoji
new PollMediaProperties
{ // Text for the answer
Text = "Yes!",
// Emoji for the answer
// Can be a custom emoji or unicode one
// Remember that bot must be in the guild where the custom emoji is
Emoji = Emote.Parse("<:wires:1214532316999974962>")
},
// Or just text
new PollMediaProperties
{
Text = "Of course!",
}
],
// You can allow users to select multiple answers
// By default, it's set to false
AllowMultiselect = true,
// Also you can set the layout of the poll
// By default, it's set to Default
// At this time, it's the only available layout type
LayoutType = PollLayout.Default
};

// Send the poll to the text channel
await textChannel.SendMessageAsync(poll: poll);
4 changes: 4 additions & 0 deletions docs/guides/polls/samples/end-poll.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Get a message with a poll
var message = await channel.GetMessageAsync(id) as IUserMessage;
// End the poll
await message.EndPollAsync();
4 changes: 4 additions & 0 deletions docs/guides/polls/samples/get-poll-voters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Get the id of the first answer in the poll
var answerId = message.Poll.Answers.First().AnswerId;
// Get the list of voters who voted for the first answer
var voters = await message.GetPollAnswerVotersAsync(answerId).FlattenAsync();
2 changes: 2 additions & 0 deletions docs/guides/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@
topicUid: Guides.BearerToken
- name: Voice
topicUid: Guides.Voice.SendingVoice
- name: Polls
topicUid: Guides.Polls
- name: Deployment
topicUid: Guides.Deployment
8 changes: 8 additions & 0 deletions src/Discord.Net.Core/DiscordConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ public class DiscordConfig
/// </remarks>
public bool UseInteractionSnowflakeDate { get; set; } = true;

/// <summary>
/// Gets or sets whether or not any responses to Discord will make an internal expiration check.
/// </summary>
/// <remarks>
/// This should generally be set to <see langword="false"/> in a development environment due to potential latency issues.
/// </remarks>
public bool ResponseInternalTimeCheck { get; set; } = true;

/// <summary>
/// Gets or sets if the Rest/Socket user <see cref="object.ToString"/> override formats the string in respect to bidirectional unicode.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion src/Discord.Net.Core/Entities/Emotes/Emote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public class Emote : IEmote, ISnowflakeEntity
/// </returns>
public string Url => CDN.GetEmojiUrl(Id, Animated);

internal Emote(ulong id, string name, bool animated)
/// <summary>
/// Creates a new instance of <see cref="Emote" />.
/// </summary>
public Emote(ulong id, string name, bool animated = false)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException("A custom emote must have a name", nameof(name));
Id = id;
Name = name;
Animated = animated;
Expand Down
Loading

0 comments on commit 48b0d9a

Please sign in to comment.