Add applicationId/guildId mapping to the interaction registrar
This commit is contained in:
parent
d2b9daac57
commit
9a2bf84a05
1 changed files with 6 additions and 20 deletions
|
@ -20,7 +20,6 @@ namespace Geekbot.Web.Controllers.Interactions
|
||||||
private readonly IGeekbotLogger _logger;
|
private readonly IGeekbotLogger _logger;
|
||||||
private readonly IInteractionCommandManager _interactionCommandManager;
|
private readonly IInteractionCommandManager _interactionCommandManager;
|
||||||
private readonly string _discordToken;
|
private readonly string _discordToken;
|
||||||
// private readonly string _applicationId;
|
|
||||||
private readonly Uri _guildCommandUri;
|
private readonly Uri _guildCommandUri;
|
||||||
|
|
||||||
public InteractionRegistrarController(IGlobalSettings globalSettings, IGeekbotLogger logger, IInteractionCommandManager interactionCommandManager)
|
public InteractionRegistrarController(IGlobalSettings globalSettings, IGeekbotLogger logger, IInteractionCommandManager interactionCommandManager)
|
||||||
|
@ -29,8 +28,12 @@ namespace Geekbot.Web.Controllers.Interactions
|
||||||
_interactionCommandManager = interactionCommandManager;
|
_interactionCommandManager = interactionCommandManager;
|
||||||
_discordToken = globalSettings.GetKey("DiscordToken");
|
_discordToken = globalSettings.GetKey("DiscordToken");
|
||||||
var applicationId = globalSettings.GetKey("DiscordApplicationId");
|
var applicationId = globalSettings.GetKey("DiscordApplicationId");
|
||||||
var runesPlayground = "131827972083548160";
|
var betaGuilds = new Dictionary<string, string>()
|
||||||
_guildCommandUri = new Uri($"https://discord.com/api/v8/applications/{applicationId}/guilds/{runesPlayground}/commands");
|
{
|
||||||
|
{ "171249478546882561", "93070552863870976" }, // Prod / Swiss Geeks
|
||||||
|
{ "181092911243329537", "131827972083548160" }, // Dev / Rune's Playground
|
||||||
|
};
|
||||||
|
_guildCommandUri = new Uri($"https://discord.com/api/v8/applications/{applicationId}/guilds/{betaGuilds[applicationId]}/commands");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
@ -58,23 +61,6 @@ namespace Geekbot.Web.Controllers.Interactions
|
||||||
operations.Remove.Add(registeredInteraction.Id);
|
operations.Remove.Add(registeredInteraction.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// foreach (var (_, command) in _interactionCommandManager.CommandsInfo)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var httpClient = HttpAbstractions.CreateDefaultClient();
|
|
||||||
// httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bot", _discordToken);
|
|
||||||
//
|
|
||||||
// await HttpAbstractions.Post(_guildCommandUri, command, httpClient);
|
|
||||||
//
|
|
||||||
// _logger.Information(LogSource.Interaction, $"Registered Interaction: {command.Name}");
|
|
||||||
// }
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// _logger.Error(LogSource.Interaction, $"Failed to register Interaction: {command.Name}", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
await Task.WhenAll(new[]
|
await Task.WhenAll(new[]
|
||||||
{
|
{
|
||||||
Create(operations.Create),
|
Create(operations.Create),
|
||||||
|
|
Loading…
Reference in a new issue