Skip to content

Commit 7ce11b0

Browse files
authored
Update OnReady.cs (#334)
* Update OnReady.cs #!components: grid-bot #!deployable-components: grid-bot Signed-off-by: Nikita Petko <[email protected]> * Update build.yml Signed-off-by: Nikita Petko <[email protected]> * Update build.yml Signed-off-by: Nikita Petko <[email protected]> * Update build.yml Signed-off-by: Nikita Petko <[email protected]> * Update build.yml Signed-off-by: Nikita Petko <[email protected]> * Update build.yml Signed-off-by: Nikita Petko <[email protected]> * Updates to system. Fix #326 Add user context commands for pub commands. --------- Signed-off-by: Nikita Petko <[email protected]>
1 parent 037e618 commit 7ce11b0

File tree

8 files changed

+52
-6
lines changed

8 files changed

+52
-6
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ jobs:
253253
}
254254
}
255255
256+
console.log(dotnetCommand);
257+
256258
try {
257259
child_process.execSync(dotnetCommand, { stdio: 'inherit' });
258260
} catch (error) {
@@ -264,13 +266,24 @@ jobs:
264266
// Zip the component, and move it to the deploy directory
265267
const zipCommand = `zip -r ${path.resolve(deployDirectory, `${componentConfig.component}.zip`)} .`;
266268
269+
console.log(zipCommand);
270+
267271
try {
268272
child_process.execSync(zipCommand, { stdio: 'inherit', cwd: componentConfig.build.component_directory });
269273
} catch (error) {
270274
core.setFailed(`Failed to zip component ${component}`);
271275
272276
return;
273277
}
278+
279+
const lsCommand = `ls -la ${deployDirectory}`
280+
try {
281+
child_process.execSync(lsCommand, { stdio: 'inherit' });
282+
} catch (error) {
283+
core.setFailed(`Failed to ls component ${component}`);
284+
285+
return;
286+
}
274287
}
275288
276289
@@ -282,7 +295,9 @@ jobs:
282295
uses: actions/upload-artifact@v4
283296
with:
284297
name: components
285-
path: ${{ steps.build-components.outputs.deploy-directory }}/*.zip
298+
path: .deploy/*.zip
299+
if-no-files-found: error
300+
include-hidden-files: true
286301

287302

288303
# No need for checkout, downloads the component archives from the

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

services/grid-bot/lib/events/Events/OnReady.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public async Task Invoke(DiscordSocketClient shard)
9494
#if DEBUG
9595
if (_discordSettings.DebugGuildId != 0)
9696
await _interactionService.RegisterCommandsToGuildAsync(_discordSettings.DebugGuildId);
97+
else
98+
await _interactionService.RegisterCommandsGloballyAsync();
9799
#else
98100
await _interactionService.RegisterCommandsGloballyAsync();
99101
#endif

0 commit comments

Comments
 (0)