Onboarding updates (#2729)
This commit is contained in:
@@ -231,7 +231,7 @@ namespace Discord
|
||||
StickerAnimationDurationTooLong = 170007,
|
||||
#endregion
|
||||
|
||||
#region Guild Scheduled Events
|
||||
#region Guild Scheduled Events (180XXX)
|
||||
CannotUpdateFinishedEvent = 180000,
|
||||
FailedStageCreation = 180002,
|
||||
#endregion
|
||||
@@ -245,5 +245,10 @@ namespace Discord
|
||||
WebhookServicesCannotBeUsedInForumChannels = 220004,
|
||||
MessageBlockedByHarmfulLinksFilter = 240000,
|
||||
#endregion
|
||||
|
||||
#region Onboarding (350XXX)
|
||||
CannotEnableOnboardingUnmetRequirements = 350000,
|
||||
CannotUpdateOnboardingBelowRequirements = 350001
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1317,5 +1317,13 @@ namespace Discord
|
||||
/// A task that represents the asynchronous creation operation. The task result contains the created <see cref="IGuildOnboarding"/>.
|
||||
/// </returns>
|
||||
Task<IGuildOnboarding> GetOnboardingAsync(RequestOptions options = null);
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the onboarding object configured for the guild.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous creation operation. The task result contains the modified <see cref="IGuildOnboarding"/>.
|
||||
/// </returns>
|
||||
Task<IGuildOnboarding> ModifyOnboardingAsync(Action<GuildOnboardingProperties> props, RequestOptions options = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Discord;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the criteria used to satisfy Onboarding constraints that are required for enabling.
|
||||
/// </summary>
|
||||
public enum GuildOnboardingMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Counts only Default Channels towards constraints.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Counts Default Channels and Questions towards constraints.
|
||||
/// </summary>
|
||||
Advanced = 1,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord;
|
||||
|
||||
/// <summary>
|
||||
/// Represents properties used to create or modify guild onboarding prompt option.
|
||||
/// </summary>
|
||||
public class GuildOnboardingPromptOptionProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the prompt option. If the value is <see langword="null" /> a new prompt will be created.
|
||||
/// The existing one will be updated otherwise.
|
||||
/// </summary>
|
||||
public ulong? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set IDs for channels a member is added to when the option is selected.
|
||||
/// </summary>
|
||||
public ulong[] ChannelIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets IDs for roles assigned to a member when the option is selected.
|
||||
/// </summary>
|
||||
public ulong[] RoleIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the emoji of the option.
|
||||
/// </summary>
|
||||
public Optional<IEmote> Emoji { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the option.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description of the option.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord;
|
||||
|
||||
/// <summary>
|
||||
/// Represents properties used to create or modify guild onboarding prompt.
|
||||
/// </summary>
|
||||
public class GuildOnboardingPromptProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the prompt. If the value is <see langword="null" /> a new prompt will be created.
|
||||
/// The existing one will be updated otherwise.
|
||||
/// </summary>
|
||||
public ulong? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets options available within the prompt.
|
||||
/// </summary>
|
||||
public GuildOnboardingPromptOptionProperties[] Options { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the prompt.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether users are limited to selecting one option for the prompt.
|
||||
/// </summary>
|
||||
public bool IsSingleSelect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the prompt is required before a user completes the onboarding flow.
|
||||
/// </summary>
|
||||
public bool IsRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the prompt is present in the onboarding flow.
|
||||
/// </summary>
|
||||
public bool IsInOnboarding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the type of the prompt.
|
||||
/// </summary>
|
||||
public GuildOnboardingPromptType Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord;
|
||||
|
||||
/// <summary>
|
||||
/// Represents properties used to create or modify guild onboarding.
|
||||
/// </summary>
|
||||
public class GuildOnboardingProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets prompts shown during onboarding and in customize community.
|
||||
/// </summary>
|
||||
public Optional<GuildOnboardingPromptProperties[]> Prompts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets channel IDs that members get opted into automatically.
|
||||
/// </summary>
|
||||
public Optional<ulong[]> ChannelIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether onboarding is enabled in the guild.
|
||||
/// </summary>
|
||||
public Optional<bool> IsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets current mode of onboarding.
|
||||
/// </summary>
|
||||
public Optional<GuildOnboardingMode> Mode { get; set;}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord;
|
||||
|
||||
@@ -31,4 +33,19 @@ public interface IGuildOnboarding
|
||||
/// Gets whether onboarding is enabled in the guild.
|
||||
/// </summary>
|
||||
bool IsEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current mode of onboarding.
|
||||
/// </summary>
|
||||
GuildOnboardingMode Mode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the server does not meet requirements to enable guild onboarding.
|
||||
/// </summary>
|
||||
bool IsBelowRequirements { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the onboarding object.
|
||||
/// </summary>
|
||||
Task ModifyAsync(Action<GuildOnboardingProperties> props, RequestOptions options = null);
|
||||
}
|
||||
|
||||
39
src/Discord.Net.Core/Extensions/GuildOnboardingExtensions.cs
Normal file
39
src/Discord.Net.Core/Extensions/GuildOnboardingExtensions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Discord;
|
||||
|
||||
public static class GuildOnboardingExtensions
|
||||
{
|
||||
public static GuildOnboardingProperties ToProperties(this IGuildOnboarding onboarding)
|
||||
=> new ()
|
||||
{
|
||||
ChannelIds = onboarding.DefaultChannelIds.ToArray(),
|
||||
IsEnabled = onboarding.IsEnabled,
|
||||
Mode = onboarding.Mode,
|
||||
Prompts = onboarding.Prompts.Select(x => x.ToProperties()).ToArray(),
|
||||
};
|
||||
|
||||
public static GuildOnboardingPromptProperties ToProperties(this IGuildOnboardingPrompt prompt)
|
||||
=> new()
|
||||
{
|
||||
Id = prompt.Id,
|
||||
Type = prompt.Type,
|
||||
IsInOnboarding = prompt.IsInOnboarding,
|
||||
IsRequired = prompt.IsRequired,
|
||||
IsSingleSelect = prompt.IsSingleSelect,
|
||||
Title = prompt.Title,
|
||||
Options = prompt.Options.Select(x => x.ToProperties()).ToArray()
|
||||
};
|
||||
|
||||
public static GuildOnboardingPromptOptionProperties ToProperties(this IGuildOnboardingPromptOption option)
|
||||
=> new()
|
||||
{
|
||||
Title = option.Title,
|
||||
ChannelIds = option.ChannelIds.ToArray(),
|
||||
Description = option.Description,
|
||||
Emoji = Optional.Create(option.Emoji),
|
||||
Id = option.Id,
|
||||
RoleIds = option.RoleIds.ToArray(),
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user