Attempt to fix bot commands
This commit is contained in:
parent
926e323569
commit
1e8f8106b0
|
@ -27,6 +27,7 @@ namespace CodexPlugin
|
|||
var response = codexAccess.RequestStorage(purchase);
|
||||
|
||||
if (string.IsNullOrEmpty(response) ||
|
||||
response == "Unable to encode manifest" ||
|
||||
response == "Purchasing not available" ||
|
||||
response == "Expiry required" ||
|
||||
response == "Expiry needs to be in future" ||
|
||||
|
|
|
@ -35,12 +35,6 @@ 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: ";
|
||||
|
@ -60,10 +54,16 @@ namespace BiblioTech
|
|||
|
||||
try
|
||||
{
|
||||
log.Log("Creating application commands...");
|
||||
foreach (var builder in builders)
|
||||
log.Log("Building application commands...");
|
||||
var commands = builders.Select(b => b.Build()).ToArray();
|
||||
|
||||
log.Log("Submitting application commands...");
|
||||
var response = await guild.BulkOverwriteApplicationCommandAsync(commands);
|
||||
|
||||
log.Log("Commands in response:");
|
||||
foreach (var cmd in response)
|
||||
{
|
||||
await guild.CreateApplicationCommandAsync(builder.Build());
|
||||
log.Log($"{cmd.Name} ({cmd.Description}) [{DescribOptions(cmd.Options)}]");
|
||||
}
|
||||
}
|
||||
catch (HttpException exception)
|
||||
|
@ -71,6 +71,17 @@ namespace BiblioTech
|
|||
var json = JsonConvert.SerializeObject(exception.Errors, Formatting.Indented);
|
||||
log.Error(json);
|
||||
}
|
||||
log.Log("Initialized.");
|
||||
}
|
||||
|
||||
private string DescribOptions(IReadOnlyCollection<SocketApplicationCommandOption> options)
|
||||
{
|
||||
return string.Join(",", options.Select(DescribeOption).ToArray());
|
||||
}
|
||||
|
||||
private string DescribeOption(SocketApplicationCommandOption option)
|
||||
{
|
||||
return $"({option.Name}[{DescribOptions(option.Options)}])";
|
||||
}
|
||||
|
||||
private async Task SlashCommandHandler(SocketSlashCommand command)
|
||||
|
|
|
@ -38,9 +38,6 @@ 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");
|
||||
|
|
Loading…
Reference in New Issue