Add option to delete app commands on startup to discord bot

This commit is contained in:
benbierens 2024-06-28 13:11:31 +02:00
parent 52a02abd3f
commit 8d32758918
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,12 @@ namespace BiblioTech
Program.AdminChecker.SetAdminChannel(adminChannels.First());
Program.RoleDriver = new RoleDriver(client, log, replacement);
if (Program.Config.DeleteCommandsAtStartup > 0)
{
log.Log("Deleting all application commands...");
await guild.DeleteApplicationCommandsAsync();
}
var builders = commands.Select(c =>
{
var msg = $"Building command '{c.Name}' with options: ";
@ -54,6 +60,7 @@ namespace BiblioTech
try
{
log.Log("Creating application commands...");
foreach (var builder in builders)
{
await guild.CreateApplicationCommandAsync(builder.Build());

View File

@ -38,6 +38,9 @@ namespace BiblioTech
[Uniform("no-discord", "nd", "NODISCORD", false, "For debugging: Bypasses all Discord API calls.")]
public int NoDiscord { get; set; } = 0;
[Uniform("delete-commands-at-startup", "dcas", "DELETECMDSATSTARTUP", false, "If > 0, deletes all app commands at startup.")]
public int DeleteCommandsAtStartup { get; set; } = 0;
public string EndpointsPath => Path.Combine(DataPath, "endpoints");
public string UserDataPath => Path.Combine(DataPath, "users");
public string LogPath => Path.Combine(DataPath, "logs");