Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OnReady.cs #334

Merged
merged 7 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ jobs:
}
}

console.log(dotnetCommand);

try {
child_process.execSync(dotnetCommand, { stdio: 'inherit' });
} catch (error) {
Expand All @@ -264,13 +266,24 @@ jobs:
// Zip the component, and move it to the deploy directory
const zipCommand = `zip -r ${path.resolve(deployDirectory, `${componentConfig.component}.zip`)} .`;

console.log(zipCommand);

try {
child_process.execSync(zipCommand, { stdio: 'inherit', cwd: componentConfig.build.component_directory });
} catch (error) {
core.setFailed(`Failed to zip component ${component}`);

return;
}

const lsCommand = `ls -la ${deployDirectory}`
try {
child_process.execSync(lsCommand, { stdio: 'inherit' });
} catch (error) {
core.setFailed(`Failed to ls component ${component}`);

return;
}
}


Expand All @@ -282,7 +295,9 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: components
path: ${{ steps.build-components.outputs.deploy-directory }}/*.zip
path: .deploy/*.zip
if-no-files-found: error
include-hidden-files: true


# No need for checkout, downloads the component archives from the
Expand Down
22 changes: 20 additions & 2 deletions services/grid-bot/lib/commands/Modules/ExecuteScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace Grid.Bot.Interactions.Public;
/// - <paramref name="gridServerFileHelper"/> cannot be null.
/// </exception>
[Group("execute", "Commands used for executing Luau code.")]
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
public partial class ExecuteScript(
ILogger logger,
GridSettings gridSettings,
Expand Down Expand Up @@ -143,6 +145,19 @@ private static string GetCodeBlockContents(string s)
{
if (string.IsNullOrEmpty(input)) return (null, null);

// Check if the input matches grid syntax error
if (GridSyntaxErrorRegex().IsMatch(input))
{
var match = GridSyntaxErrorRegex().Match(input);
var line = match.Groups[1].Value;
var error = match.Groups[2].Value;

input = $"Line {line}: {error}";
}

// Replace backticks with escaped backticks
input = input.Replace("`", "\\`");

if (input.Length > _maxErrorLength)
{
var maxSize = _scriptsSettings.ScriptExecutionMaxFileSizeKb;
Expand All @@ -160,6 +175,9 @@ private static string GetCodeBlockContents(string s)
{
if (string.IsNullOrEmpty(input)) return (null, null);

// Replace backticks with escaped backticks
input = input.Replace("`", "\\`");

if (input.Length > _maxResultLength)
{
var maxSize = _scriptsSettings.ScriptExecutionMaxResultSizeKb;
Expand Down Expand Up @@ -259,10 +277,10 @@ private async Task<bool> ParseLuaAsync(string input)
}

var embed = new EmbedBuilder()
.WithTitle("Luau Syntax Error")
.WithTitle("Lua Error")
.WithAuthor(Context.User)
.WithCurrentTimestamp()
.WithColor(0xff, 0x00, 0x00)
.WithColor(Color.Red)
.WithDescription($"```\n{errorString}\n```")
.Build();

Expand Down
3 changes: 3 additions & 0 deletions services/grid-bot/lib/commands/Modules/Render.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Grid.Bot.Interactions.Public;
using System;
using System.Threading.Tasks;

using Discord;
using Discord.Interactions;

using Logging;
Expand Down Expand Up @@ -31,6 +32,8 @@ namespace Grid.Bot.Interactions.Public;
/// - <paramref name="adminUtility"/> cannot be null.
/// </exception>
[Group("render", "Commands used for rendering a Roblox character.")]
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
public class Render(
AvatarSettings avatarSettings,
ILogger logger,
Expand Down
2 changes: 2 additions & 0 deletions services/grid-bot/lib/commands/Modules/Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Grid.Bot.Interactions.Public;
/// - <paramref name="gridServerFileHelper"/> cannot be null.
/// </exception>
[Group("support", "Commands used for grid-bot-support.")]
[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)]
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)]
public class Support(
GridSettings gridSettings,
GlobalSettings globalSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ namespace Grid.Bot.Interactions.Private;
/// - <paramref name="clientSettingsClient"/> cannot be null.
/// - <paramref name="clientSettingsClientSettings"/> cannot be null.
/// </exception>
[Group("clientsettings", "Manage the client settings.")]
[RequireBotRole(BotRole.Administrator)]
[CommandContextType(InteractionContextType.Guild)]
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
[Group("clientsettings", "Manage the client settings.")]
public class ClientSettingsModule(IClientSettingsClient clientSettingsClient, ClientSettingsClientSettings clientSettingsClientSettings) : InteractionModuleBase<ShardedInteractionContext>
{
private readonly IClientSettingsClient _clientSettingsClient = clientSettingsClient ?? throw new ArgumentNullException(nameof(clientSettingsClient));
Expand Down
4 changes: 3 additions & 1 deletion services/grid-bot/lib/commands/PrivateModules/Maintenance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ namespace Grid.Bot.Interactions.Private;
/// - <paramref name="discordSettings"/> cannot be null.
/// - <paramref name="discordShardedClient"/> cannot be null.
/// </exception>
[Group("maintenance", "Commands used for grid-bot-maintenance.")]
[RequireBotRole(BotRole.Administrator)]
[CommandContextType(InteractionContextType.Guild)]
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
[Group("maintenance", "Commands used for grid-bot-maintenance.")]
public class Maintenance(
MaintenanceSettings maintenanceSettings,
DiscordSettings discordSettings,
Expand Down
4 changes: 3 additions & 1 deletion services/grid-bot/lib/commands/PrivateModules/Roles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace Grid.Bot.Interactions.Private;
/// - <paramref name="discordRolesSettings"/> cannot be null.
/// - <paramref name="adminUtility"/> cannot be null.
/// </exception>
[Group("role", "Commands used for updating user bot roles.")]
[RequireBotRole(BotRole.Administrator)]
[CommandContextType(InteractionContextType.Guild)]
[IntegrationType(ApplicationIntegrationType.GuildInstall)]
[Group("role", "Commands used for updating user bot roles.")]
public class Roles(
DiscordRolesSettings discordRolesSettings,
IAdminUtility adminUtility
Expand Down
2 changes: 2 additions & 0 deletions services/grid-bot/lib/events/Events/OnReady.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public async Task Invoke(DiscordSocketClient shard)
#if DEBUG
if (_discordSettings.DebugGuildId != 0)
await _interactionService.RegisterCommandsToGuildAsync(_discordSettings.DebugGuildId);
else
await _interactionService.RegisterCommandsGloballyAsync();
#else
await _interactionService.RegisterCommandsGloballyAsync();
#endif
Expand Down
Loading