Skip to content

Commit 1e8f810

Browse files
committed
Attempt to fix bot commands
1 parent 926e323 commit 1e8f810

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

ProjectPlugins/CodexPlugin/MarketplaceAccess.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public IStoragePurchaseContract RequestStorage(StoragePurchaseRequest purchase)
2727
var response = codexAccess.RequestStorage(purchase);
2828

2929
if (string.IsNullOrEmpty(response) ||
30+
response == "Unable to encode manifest" ||
3031
response == "Purchasing not available" ||
3132
response == "Expiry required" ||
3233
response == "Expiry needs to be in future" ||

Tools/BiblioTech/CommandHandler.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ 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-
4438
var builders = commands.Select(c =>
4539
{
4640
var msg = $"Building command '{c.Name}' with options: ";
@@ -60,17 +54,34 @@ private async Task Client_Ready()
6054

6155
try
6256
{
63-
log.Log("Creating application commands...");
64-
foreach (var builder in builders)
57+
log.Log("Building application commands...");
58+
var commands = builders.Select(b => b.Build()).ToArray();
59+
60+
log.Log("Submitting application commands...");
61+
var response = await guild.BulkOverwriteApplicationCommandAsync(commands);
62+
63+
log.Log("Commands in response:");
64+
foreach (var cmd in response)
6565
{
66-
await guild.CreateApplicationCommandAsync(builder.Build());
66+
log.Log($"{cmd.Name} ({cmd.Description}) [{DescribOptions(cmd.Options)}]");
6767
}
6868
}
6969
catch (HttpException exception)
7070
{
7171
var json = JsonConvert.SerializeObject(exception.Errors, Formatting.Indented);
7272
log.Error(json);
7373
}
74+
log.Log("Initialized.");
75+
}
76+
77+
private string DescribOptions(IReadOnlyCollection<SocketApplicationCommandOption> options)
78+
{
79+
return string.Join(",", options.Select(DescribeOption).ToArray());
80+
}
81+
82+
private string DescribeOption(SocketApplicationCommandOption option)
83+
{
84+
return $"({option.Name}[{DescribOptions(option.Options)}])";
7485
}
7586

7687
private async Task SlashCommandHandler(SocketSlashCommand command)

Tools/BiblioTech/Configuration.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ 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-
4441
public string EndpointsPath => Path.Combine(DataPath, "endpoints");
4542
public string UserDataPath => Path.Combine(DataPath, "users");
4643
public string LogPath => Path.Combine(DataPath, "logs");

0 commit comments

Comments
 (0)