forked from Aiko-IT-Systems/DisCatSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplicationCommandsConfiguration.cs
113 lines (98 loc) · 4.44 KB
/
ApplicationCommandsConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using DisCatSharp.Attributes;
using Microsoft.Extensions.DependencyInjection;
namespace DisCatSharp.ApplicationCommands;
/// <summary>
/// A configuration for a <see cref="ApplicationCommandsExtension"/>
/// </summary>
public sealed class ApplicationCommandsConfiguration
{
/// <summary>
/// <para>Sets the service provider.</para>
/// <para>Objects in this provider are used when instantiating application command modules.</para>
/// <para>This allows passing data around without resorting to static members.</para>
/// <para>Defaults to <see langword="null"/>.</para>
/// </summary>
public IServiceProvider ServiceProvider { internal get; set; } = new ServiceCollection().BuildServiceProvider(true);
/// <summary>
/// <para>This option enables the default help command.</para>
/// <para>Disabling this will allow you to make your own help command.</para>
/// <para>Defaults to <see langword="true"/>.</para>
/// </summary>
public bool EnableDefaultHelp { internal get; set; } = true;
/// <summary>
/// <para>This option enables the default help command with user apps capability.</para>
/// <para>Mutually exclusive with <see cref="EnableDefaultHelp"/>.</para>
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
[DiscordInExperiment, RequiresFeature(Features.Experiment, "Requires you to be part of the user apps experiment and the apps owner.")]
public bool EnableDefaultUserAppsHelp { get; set; } = false;
/// <summary>
/// This option enables the localization feature.
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
public bool EnableLocalization { internal get; set; } = false;
// TODO: Check if it interferes with callback hints
/// <summary>
/// <para>Automatically defer all responses.</para>
/// <note type="note">If you enable this, you can't use CreateResponse. Use EditResponse instead.</note>
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
public bool AutoDefer { internal get; set; } = false;
/// <summary>
/// <para>This option informs the module to check through all guilds whether the
/// <see target="_blank" alt="Application Commands Scope" href="https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes">application.commands</see> scope is set.</para>
/// <note type="warning">This will take quite a while, when the bot is on more than 1k guilds.</note>
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
public bool CheckAllGuilds { internal get; set; } = false;
/// <summary>
/// <para>This option increases the debug output of the module.</para>
/// <note type="warning">
/// <para>This is not recommended for production use.</para>
/// <para>Enable this option only if DisCatSharp support advises you to do so.</para>
/// </note>
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
public bool DebugStartup { internal get; set; } = false;
/// <summary>
/// <para>Whether to only generate translations files and abort after that.</para>
/// <para>Defaults to <see langword="false"/>.</para>
/// </summary>
public bool GenerateTranslationFilesOnly { internal get; set; } = false;
/// <summary>
/// Whether to enable unit test mode.
/// </summary>
internal bool UnitTestMode { get; set; } = false;
/// <summary>
/// Creates a new configuration with default values.
/// </summary>
[ActivatorUtilitiesConstructor]
public ApplicationCommandsConfiguration()
{ }
/// <summary>
/// Utilized via dependency injection pipeline.
/// </summary>
/// <param name="provider">The service provider.</param>
[ActivatorUtilitiesConstructor]
public ApplicationCommandsConfiguration(IServiceProvider provider)
{
this.ServiceProvider = provider;
}
/// <summary>
/// Creates a new instance of <see cref="ApplicationCommandsConfiguration"/>, copying the properties of another configuration.
/// </summary>
/// <param name="acc">Configuration the properties of which are to be copied.</param>
public ApplicationCommandsConfiguration(ApplicationCommandsConfiguration acc)
{
this.EnableDefaultHelp = acc.EnableDefaultHelp;
this.ServiceProvider = acc.ServiceProvider;
this.DebugStartup = acc.DebugStartup;
this.CheckAllGuilds = acc.CheckAllGuilds;
this.AutoDefer = acc.AutoDefer;
this.EnableLocalization = acc.EnableLocalization;
this.GenerateTranslationFilesOnly = acc.GenerateTranslationFilesOnly;
this.EnableDefaultUserAppsHelp = acc.EnableDefaultUserAppsHelp;
this.UnitTestMode = acc.UnitTestMode;
}
}