Skip to content

Commit 8d32758

Browse files
committed
Add option to delete app commands on startup to discord bot
1 parent 52a02ab commit 8d32758

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Tools/BiblioTech/CommandHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ private async Task Client_Ready()
3535
Program.AdminChecker.SetAdminChannel(adminChannels.First());
3636
Program.RoleDriver = new RoleDriver(client, log, replacement);
3737

38+
if (Program.Config.DeleteCommandsAtStartup > 0)
39+
{
40+
log.Log("Deleting all application commands...");
41+
await guild.DeleteApplicationCommandsAsync();
42+
}
43+
3844
var builders = commands.Select(c =>
3945
{
4046
var msg = $"Building command '{c.Name}' with options: ";
@@ -54,6 +60,7 @@ private async Task Client_Ready()
5460

5561
try
5662
{
63+
log.Log("Creating application commands...");
5764
foreach (var builder in builders)
5865
{
5966
await guild.CreateApplicationCommandAsync(builder.Build());

Tools/BiblioTech/Configuration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class Configuration
3838
[Uniform("no-discord", "nd", "NODISCORD", false, "For debugging: Bypasses all Discord API calls.")]
3939
public int NoDiscord { get; set; } = 0;
4040

41+
[Uniform("delete-commands-at-startup", "dcas", "DELETECMDSATSTARTUP", false, "If > 0, deletes all app commands at startup.")]
42+
public int DeleteCommandsAtStartup { get; set; } = 0;
43+
4144
public string EndpointsPath => Path.Combine(DataPath, "endpoints");
4245
public string UserDataPath => Path.Combine(DataPath, "users");
4346
public string LogPath => Path.Combine(DataPath, "logs");

0 commit comments

Comments
 (0)