Skip to content

Commit 3d6a316

Browse files
committed
#336: Text commands clean ups
~ Rename references of interactions to commands. Drop need for summary attribute on command arguments as it is unused within the stack. ~ Clean up constructors of some handlers removing uneeded arguments.
1 parent 1df7a25 commit 3d6a316

File tree

5 files changed

+19
-86
lines changed

5 files changed

+19
-86
lines changed

services/grid-bot/lib/commands/Modules/Commands/ExecuteScript.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Grid.Bot.Commands.Public;
3131
using ClientJob = Client.Job;
3232

3333
/// <summary>
34-
/// Interaction handler for executing Luau code.
34+
/// Command handler for executing Luau code.
3535
/// </summary>
3636
/// <remarks>
3737
/// Construct a new instance of <see cref="ExecuteScript"/>.
@@ -301,10 +301,7 @@ private async Task<bool> ParseLuaAsync(string input)
301301
/// </summary>
302302
/// <param name="script">The script to execute.</param>
303303
[Command("execute"), Summary("Execute a script via raw text."), Alias("ex", "exc", "x")]
304-
public async Task ExecuteScriptFromTextAsync(
305-
[Summary("The script to execute."), Remainder]
306-
string script = ""
307-
)
304+
public async Task ExecuteScriptFromTextAsync([Remainder] string script = "")
308305
{
309306
using var _ = Context.Channel.EnterTypingState();
310307

services/grid-bot/lib/commands/Modules/Commands/Render.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Grid.Bot.Commands.Public;
1212
using Extensions;
1313

1414
/// <summary>
15-
/// Interaction handler for rendering a Roblox character.
15+
/// Command handler for rendering a Roblox character.
1616
/// </summary>
1717
/// <remarks>
1818
/// Construct a new instance of <see cref="Render"/>.
@@ -74,10 +74,7 @@ protected override async Task BeforeExecuteAsync(CommandInfo command)
7474
/// </summary>
7575
/// <param name="userNameOrId">The ID of the Roblox user.</param>
7676
[Command("render"), Summary("Renders a Roblox character by Roblox user ID."), Alias("r")]
77-
public async Task DoRenderAsync(
78-
[Summary("The ID or the user name of the Roblox user.")]
79-
string userNameOrId
80-
)
77+
public async Task DoRenderAsync(string userNameOrId)
8178
{
8279
using var _ = Context.Channel.EnterTypingState();
8380

services/grid-bot/lib/commands/PrivateModules/Commands/ClientSettings.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Grid.Bot.Commands.Private;
2020
using Extensions;
2121

2222
/// <summary>
23-
/// Represents the interaction for ClientSettings.
23+
/// Represents the command for ClientSettings.
2424
/// </summary>
2525
/// <remarks>
2626
/// Construct a new instance of <see cref="ClientSettingsModule"/>.
@@ -67,13 +67,7 @@ public enum ClientSettingType
6767
/// <param name="useApiKey">Should the API key be used? This will allow the application to be returned from the client settings API even if $allowed on the backend is false.</param>
6868
[Command("get_all"), Summary("Gets all client settings for the specified application.")]
6969
[Alias("getall", "all")]
70-
public async Task GetAllAsync(
71-
[Summary("The name of the application to get the client settings for.")]
72-
string applicationName,
73-
74-
[Summary("Should the API key be used? This will allow the application to be returned from the client settings API even if $allowed on the backend is false.")]
75-
bool useApiKey = false
76-
)
70+
public async Task GetAllAsync(string applicationName, bool useApiKey = false)
7771
{
7872
using var _ = Context.Channel.EnterTypingState();
7973

@@ -111,19 +105,7 @@ await this.ReplyWithReferenceAsync(
111105
/// <param name="reference">The reference for the application.</param>
112106
/// <param name="isAllowedFromApi">Is the application allowed to be written to from the API?</param>
113107
[Command("import"), Summary("Imports the client settings for the specified application.")]
114-
public async Task ImportAsync(
115-
[Summary("The name of the application to import the client settings for.")]
116-
string applicationName,
117-
118-
[Summary("The dependencies for the application.")]
119-
string dependencies = null,
120-
121-
[Summary("The reference for the application.")]
122-
string reference = null,
123-
124-
[Summary("Is the application allowed to be written to from the API?")]
125-
bool isAllowedFromApi = false
126-
)
108+
public async Task ImportAsync(string applicationName, string dependencies = null, string reference = null, bool isAllowedFromApi = false)
127109
{
128110
var applicationSettings = Context.Message.Attachments.FirstOrDefault();
129111
if (applicationSettings is null)
@@ -170,16 +152,10 @@ await this.ReplyWithReferenceAsync(
170152
/// <param name="applicationName">The name of the application.</param>
171153
/// <param name="settingName">The name of the setting.</param>
172154
[Command("get"), Summary("Gets a client setting for the specified application.")]
173-
public async Task GetAsync(
174-
[Summary("The name of the application to get the client setting for.")]
175-
string applicationName,
176-
177-
[Summary("The name of the setting to get.")]
178-
string settingName
179-
)
155+
public async Task GetAsync(string applicationName, string settingName)
180156
{
181157
if (string.IsNullOrWhiteSpace(applicationName))
182-
{
158+
{
183159
await this.ReplyWithReferenceAsync(
184160
text: "Please specify an application name."
185161
);
@@ -233,19 +209,7 @@ await this.ReplyWithReferenceAsync(
233209
/// <param name="settingType">The type of the setting.</param>
234210
/// <param name="settingValue">The value of the setting.</param>
235211
[Command("set"), Summary("Sets a client setting for the specified application.")]
236-
public async Task SetAsync(
237-
[Summary("The name of the application to set the client setting for.")]
238-
string applicationName,
239-
240-
[Summary("The name of the setting to set.")]
241-
string settingName,
242-
243-
[Summary("The type of the setting to set.")]
244-
ClientSettingType settingType = ClientSettingType.String,
245-
246-
[Summary("The value of the setting to set.")]
247-
string settingValue = ""
248-
)
212+
public async Task SetAsync(string applicationName, string settingName, ClientSettingType settingType = ClientSettingType.String, string settingValue = "")
249213
{
250214
if (string.IsNullOrWhiteSpace(applicationName))
251215
{

services/grid-bot/lib/commands/PrivateModules/Commands/Maintenance.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Grid.Bot.Commands.Private;
1212
using Extensions;
1313

1414
/// <summary>
15-
/// Interaction handler for the maintenance commands.
15+
/// Command handler for the maintenance commands.
1616
/// </summary>
1717
/// <remarks>
1818
/// Construct a new instance of <see cref="Maintenance"/>.
@@ -46,10 +46,7 @@ private static string GetStatusText(string updateText)
4646
/// </summary>
4747
/// <param name="statusText">The status text to set.</param>
4848
[Command("enable"), Summary("Enables maintenance mode.")]
49-
public async Task EnableMaintenanceAsync(
50-
[Summary("The status text to set."), Remainder]
51-
string statusText = null
52-
)
49+
public async Task EnableMaintenanceAsync([Remainder] string statusText = null)
5350
{
5451
if (_maintenanceSettings.MaintenanceEnabled)
5552
{
@@ -107,10 +104,7 @@ public async Task DisableMaintenanceAsync()
107104
/// </summary>
108105
/// <param name="statusText">The status text to set.</param>
109106
[Command("update"), Summary("Updates the maintenance status text.")]
110-
public async Task UpdateMaintenanceStatusTextAsync(
111-
[Summary("The status text to set."), Remainder]
112-
string statusText = null
113-
)
107+
public async Task UpdateMaintenanceStatusTextAsync([Remainder] string statusText = null)
114108
{
115109
if (!_maintenanceSettings.MaintenanceEnabled)
116110
{

services/grid-bot/lib/commands/PrivateModules/Commands/Roles.cs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,18 @@ namespace Grid.Bot.Commands.Private;
1111
using Extensions;
1212

1313
/// <summary>
14-
/// Interaction handler for updating user bot roles.
14+
/// Command handler for updating user bot roles.
1515
/// </summary>
1616
/// <remarks>
1717
/// Construct a new instance of <see cref="Roles"/>.
1818
/// </remarks>
19-
/// <param name="discordRolesSettings">The <see cref="DiscordRolesSettings"/>.</param>
2019
/// <param name="adminUtility">The <see cref="IAdminUtility"/>.</param>
21-
/// <exception cref="ArgumentNullException">
22-
/// - <paramref name="discordRolesSettings"/> cannot be null.
23-
/// - <paramref name="adminUtility"/> cannot be null.
24-
/// </exception>
20+
/// <exception cref="ArgumentNullException"><paramref name="adminUtility"/> cannot be null.</exception>
2521
[LockDownCommand(BotRole.Administrator)]
2622
[RequireBotRole(BotRole.Administrator)]
2723
[Group("role"), Summary("Commands used for updating user bot roles."), Alias("roles")]
28-
public class Roles(
29-
DiscordRolesSettings discordRolesSettings,
30-
IAdminUtility adminUtility
31-
) : ModuleBase
24+
public class Roles(IAdminUtility adminUtility) : ModuleBase
3225
{
33-
private readonly DiscordRolesSettings _discordRolesSettings = discordRolesSettings ?? throw new ArgumentNullException(nameof(discordRolesSettings));
3426
private readonly IAdminUtility _adminUtility = adminUtility ?? throw new ArgumentNullException(nameof(adminUtility));
3527

3628

@@ -40,12 +32,7 @@ IAdminUtility adminUtility
4032
/// <param name="user">The user to update.</param>
4133
/// <param name="role">The role to update to.</param>
4234
[Command("update"), Summary("Updates the user's bot role.")]
43-
public async Task UpdateRoleAsync(
44-
[Summary("The user to update.")]
45-
IUser user,
46-
[Summary("The role to update to.")]
47-
BotRole role = BotRole.Default
48-
)
35+
public async Task UpdateRoleAsync(IUser user, BotRole role = BotRole.Default)
4936
{
5037
if (user.IsBot)
5138
{
@@ -94,10 +81,7 @@ public async Task UpdateRoleAsync(
9481
/// </summary>
9582
/// <param name="user">The user to blacklist.</param>
9683
[Command("blacklist"), Summary("Blacklists the user.")]
97-
public async Task BlacklistUserAsync(
98-
[Summary("The user to blacklist.")]
99-
IUser user
100-
)
84+
public async Task BlacklistUserAsync(IUser user)
10185
{
10286
if (user.IsBot)
10387
{
@@ -130,10 +114,7 @@ IUser user
130114
/// </summary>
131115
/// <param name="user">The user to unblacklist.</param>
132116
[Command("unblacklist"), Summary("Unblacklists the user.")]
133-
public async Task UnblacklistUserAsync(
134-
[Summary("The user to unblacklist.")]
135-
IUser user
136-
)
117+
public async Task UnblacklistUserAsync(IUser user)
137118
{
138119
if (user.IsBot)
139120
{

0 commit comments

Comments
 (0)