Skip to content

Commit

Permalink
Merge pull request #9 from minisbett/master
Browse files Browse the repository at this point in the history
release: version 2.0.1
  • Loading branch information
minisbett authored Jan 15, 2024
2 parents 865f178 + dc1565d commit 6f2c62d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
55 changes: 51 additions & 4 deletions huisbot/Modules/CSharpRepl.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Discord;
using Discord.Interactions;
using Discord.WebSocket;
using huisbot.Services;
using huisbot.Utilities.Discord;
using Microsoft.CodeAnalysis.CSharp.Scripting;
Expand Down Expand Up @@ -93,16 +94,16 @@ public async Task CSharpReplAsync(
ScriptOptions options = ScriptOptions.Default.AddReferences(_references).AddImports(_imports);

// Construct the script globals, which contains variables for the script to be accessable.
var globals = new
var globals = new ScriptGlobals()
{
Client = Context.Client,
User = Context.User,
Channel = Context.Channel,
Guild = Context.Guild,
ServiceProvider = _provider,
Config = _config,
Osu = _osu,
Huis = _huis,
OsuApi = _osu,
HuisApi = _huis,
};

// Respond to the interaction because the script might take more than the 3 second timeout on interaction responses.
Expand Down Expand Up @@ -134,7 +135,7 @@ public async Task CSharpReplAsync(
string str = Inspect(state.Exception ?? state.ReturnValue);

// As a safety measure, replace secrets from the config with a placeholder.
foreach (string secret in new string[] { "BOT_TOKEN", "OSU_API_KEY", "HUIS_ONION_KEY" })
foreach (string secret in new string[] { "BOT_TOKEN", "OSU_API_KEY", "HUIS_ONION_KEY", "OSU_OAUTH_CLIENT_ID", "OSU_OAUTH_CLIENT_SECRET" })
str = str.Replace(_config.GetValue<string>(secret), "<censored>");

// If the string representation is too long, send a file containing it.
Expand Down Expand Up @@ -250,4 +251,50 @@ string InspectProperty(object obj)
// Return the built string.
return builder.ToString();
}

/// <summary>
/// Represents the globals that are available to the script.
/// </summary>
public class ScriptGlobals
{
/// <summary>
/// The bot client.
/// </summary>
public required DiscordSocketClient Client { get; init; }

/// <summary>
/// The user that executed the command.
/// </summary>
public required SocketUser User { get; init; }

/// <summary>
/// The channel in which the command was executed.
/// </summary>
public required ISocketMessageChannel Channel { get; init; }

/// <summary>
/// The guild in which the command was executed.
/// </summary>
public required SocketGuild Guild { get; init; }

/// <summary>
/// The service provider of the application.
/// </summary>
public required IServiceProvider ServiceProvider { get; init; }

/// <summary>
/// The configuration of the application.
/// </summary>
public required IConfiguration Config { get; init; }

/// <summary>
/// The osu! api service.
/// </summary>
public required OsuApiService OsuApi { get; init; }

/// <summary>
/// The huis api service.
/// </summary>
public required HuisApiService HuisApi { get; init; }
}
}
2 changes: 1 addition & 1 deletion huisbot/Modules/Miscellaneous/EffMissCount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using huisbot.Models.Osu;
using huisbot.Utilities.Discord;

namespace huisbot.Modules.Utility.Miscellaneous;
namespace huisbot.Modules.Miscellaneous;

/// <summary>
/// The partial interaction module for the effmisscount command.
Expand Down
2 changes: 1 addition & 1 deletion huisbot/Modules/Miscellaneous/Miscellaneous.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Discord.Interactions;
using huisbot.Services;

namespace huisbot.Modules.Utility.Miscellaneous;
namespace huisbot.Modules.Miscellaneous;

/// <summary>
/// The partial interaction module for the misc group & various subcommands, providing miscellaneous utility commands.
Expand Down
2 changes: 1 addition & 1 deletion huisbot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Program
/// <summary>
/// The version of the application.
/// </summary>
public const string VERSION = "2.0.0";
public const string VERSION = "2.0.1";

/// <summary>
/// The startup time of the application.
Expand Down

0 comments on commit 6f2c62d

Please sign in to comment.