From 5d15a973f1b84454da9e3603865611f79b373a6e Mon Sep 17 00:00:00 2001 From: Ske Date: Sat, 15 Jun 2019 12:03:07 +0200 Subject: [PATCH] Add customization of invite link client ID. Closes #77. --- PluralKit.Bot/BotConfig.cs | 1 + PluralKit.Bot/Commands/MiscCommands.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/BotConfig.cs b/PluralKit.Bot/BotConfig.cs index 87c2035a..d941fc70 100644 --- a/PluralKit.Bot/BotConfig.cs +++ b/PluralKit.Bot/BotConfig.cs @@ -3,5 +3,6 @@ namespace PluralKit.Bot public class BotConfig { public string Token { get; set; } + public ulong? ClientId { get; set; } } } \ No newline at end of file diff --git a/PluralKit.Bot/Commands/MiscCommands.cs b/PluralKit.Bot/Commands/MiscCommands.cs index d678c701..13b1e29c 100644 --- a/PluralKit.Bot/Commands/MiscCommands.cs +++ b/PluralKit.Bot/Commands/MiscCommands.cs @@ -4,11 +4,13 @@ using Discord.Commands; namespace PluralKit.Bot.Commands { public class MiscCommands: ModuleBase { + public BotConfig BotConfig { get; set; } + [Command("invite")] [Remarks("invite")] - public async Task Invite() { - var info = await Context.Client.GetApplicationInfoAsync(); - + public async Task Invite() + { + var clientId = BotConfig.ClientId ?? (await Context.Client.GetApplicationInfoAsync()).Id; var permissions = new GuildPermissions( addReactions: true, attachFiles: true, @@ -20,7 +22,7 @@ namespace PluralKit.Bot.Commands { ); // TODO: allow customization of invite ID - var invite = $"https://discordapp.com/oauth2/authorize?client_id={info.Id}&scope=bot&permissions={permissions.RawValue}"; + var invite = $"https://discordapp.com/oauth2/authorize?client_id={clientId}&scope=bot&permissions={permissions.RawValue}"; await Context.Channel.SendMessageAsync($"{Emojis.Success} Use this link to add PluralKit to your server:\n<{invite}>"); } }