Skip to content

Commit e524aeb

Browse files
committed
Updates to system.
Fix #326 Add user context commands for pub commands.
1 parent 660e1ea commit e524aeb

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ namespace Grid.Bot.Interactions.Public;
5858
/// - <paramref name="gridServerFileHelper"/> cannot be null.
5959
/// </exception>
6060
[Group("execute", "Commands used for executing Luau code.")]
61+
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
62+
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
6163
public partial class ExecuteScript(
6264
ILogger logger,
6365
GridSettings gridSettings,
@@ -143,6 +145,19 @@ private static string GetCodeBlockContents(string s)
143145
{
144146
if (string.IsNullOrEmpty(input)) return (null, null);
145147

148+
// Check if the input matches grid syntax error
149+
if (GridSyntaxErrorRegex().IsMatch(input))
150+
{
151+
var match = GridSyntaxErrorRegex().Match(input);
152+
var line = match.Groups[1].Value;
153+
var error = match.Groups[2].Value;
154+
155+
input = $"Line {line}: {error}";
156+
}
157+
158+
// Replace backticks with escaped backticks
159+
input = input.Replace("`", "\\`");
160+
146161
if (input.Length > _maxErrorLength)
147162
{
148163
var maxSize = _scriptsSettings.ScriptExecutionMaxFileSizeKb;
@@ -160,6 +175,9 @@ private static string GetCodeBlockContents(string s)
160175
{
161176
if (string.IsNullOrEmpty(input)) return (null, null);
162177

178+
// Replace backticks with escaped backticks
179+
input = input.Replace("`", "\\`");
180+
163181
if (input.Length > _maxResultLength)
164182
{
165183
var maxSize = _scriptsSettings.ScriptExecutionMaxResultSizeKb;
@@ -259,10 +277,10 @@ private async Task<bool> ParseLuaAsync(string input)
259277
}
260278

261279
var embed = new EmbedBuilder()
262-
.WithTitle("Luau Syntax Error")
280+
.WithTitle("Lua Error")
263281
.WithAuthor(Context.User)
264282
.WithCurrentTimestamp()
265-
.WithColor(0xff, 0x00, 0x00)
283+
.WithColor(Color.Red)
266284
.WithDescription($"```\n{errorString}\n```")
267285
.Build();
268286

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace Grid.Bot.Interactions.Public;
33
using System;
44
using System.Threading.Tasks;
55

6+
using Discord;
67
using Discord.Interactions;
78

89
using Logging;
@@ -31,6 +32,8 @@ namespace Grid.Bot.Interactions.Public;
3132
/// - <paramref name="adminUtility"/> cannot be null.
3233
/// </exception>
3334
[Group("render", "Commands used for rendering a Roblox character.")]
35+
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
36+
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
3437
public class Render(
3538
AvatarSettings avatarSettings,
3639
ILogger logger,

services/grid-bot/lib/commands/Modules/Support.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ namespace Grid.Bot.Interactions.Public;
2828
/// - <paramref name="gridServerFileHelper"/> cannot be null.
2929
/// </exception>
3030
[Group("support", "Commands used for grid-bot-support.")]
31+
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
32+
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
3133
public class Support(
3234
GridSettings gridSettings,
3335
GlobalSettings globalSettings,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ namespace Grid.Bot.Interactions.Private;
2828
/// - <paramref name="clientSettingsClient"/> cannot be null.
2929
/// - <paramref name="clientSettingsClientSettings"/> cannot be null.
3030
/// </exception>
31-
[Group("clientsettings", "Manage the client settings.")]
3231
[RequireBotRole(BotRole.Administrator)]
32+
[CommandContextType(InteractionContextType.Guild)]
33+
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
34+
[Group("clientsettings", "Manage the client settings.")]
3335
public class ClientSettingsModule(IClientSettingsClient clientSettingsClient, ClientSettingsClientSettings clientSettingsClientSettings) : InteractionModuleBase<ShardedInteractionContext>
3436
{
3537
private readonly IClientSettingsClient _clientSettingsClient = clientSettingsClient ?? throw new ArgumentNullException(nameof(clientSettingsClient));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ namespace Grid.Bot.Interactions.Private;
2121
/// - <paramref name="discordSettings"/> cannot be null.
2222
/// - <paramref name="discordShardedClient"/> cannot be null.
2323
/// </exception>
24-
[Group("maintenance", "Commands used for grid-bot-maintenance.")]
2524
[RequireBotRole(BotRole.Administrator)]
25+
[CommandContextType(InteractionContextType.Guild)]
26+
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
27+
[Group("maintenance", "Commands used for grid-bot-maintenance.")]
2628
public class Maintenance(
2729
MaintenanceSettings maintenanceSettings,
2830
DiscordSettings discordSettings,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ namespace Grid.Bot.Interactions.Private;
2020
/// - <paramref name="discordRolesSettings"/> cannot be null.
2121
/// - <paramref name="adminUtility"/> cannot be null.
2222
/// </exception>
23-
[Group("role", "Commands used for updating user bot roles.")]
2423
[RequireBotRole(BotRole.Administrator)]
24+
[CommandContextType(InteractionContextType.Guild)]
25+
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
26+
[Group("role", "Commands used for updating user bot roles.")]
2527
public class Roles(
2628
DiscordRolesSettings discordRolesSettings,
2729
IAdminUtility adminUtility

0 commit comments

Comments
 (0)