feat: dynamically show primary command prefix

This commit is contained in:
rladenson 2024-12-31 08:09:18 -07:00 committed by Petal Ladenson
parent 1d50022d6d
commit edfc6714d6
30 changed files with 202 additions and 197 deletions

View file

@ -8,7 +8,7 @@ namespace PluralKit.Bot;
public class Help
{
private static string Description = "PluralKit is a bot designed for plural communities on Discord, and is open for anyone to use. It allows you to register systems, maintain system information, set up message proxying, log switches, and more.\n\n" +
"**System recovery:** in the case of your Discord account getting lost or deleted, the PluralKit staff can help you recover your system, **only if you save the system token from `pk;token`**. See [this FAQ entry](https://pluralkit.me/faq/#can-i-recover-my-system-if-i-lose-access-to-my-discord-account) for more details.\n\n" +
"**System recovery:** in the case of your Discord account getting lost or deleted, the PluralKit staff can help you recover your system, **only if you save the system token from `{prefix}token`**. See [this FAQ entry](https://pluralkit.me/faq/#can-i-recover-my-system-if-i-lose-access-to-my-discord-account) for more details.\n\n" +
"If PluralKit is useful to you, please consider donating on [Patreon](https://patreon.com/pluralkit) or [Buy Me A Coffee](https://buymeacoffee.com/pluralkit).\n" +
"## Use the buttons below to see more info!";
@ -48,11 +48,11 @@ public class Help
String.Join("\n", new[]
{
"To get started using PluralKit, try running the following commands (of course replacing the relevant names with your own):",
"**1**. `pk;system new` - Create a system (if you haven't already)",
"**2**. `pk;member add John` - Add a new member to your system",
"**3**. `pk;member John proxy [text]` - Set up [square brackets] as proxy tags",
"**1**. `{prefix}system new` - Create a system (if you haven't already)",
"**2**. `{prefix}member add John` - Add a new member to your system",
"**3**. `{prefix}member John proxy [text]` - Set up [square brackets] as proxy tags",
"**4**. You're done! You can now type [a message in brackets] and it'll be proxied appropriately.",
"**5**. Optionally, you may set an avatar from the URL of an image with `pk;member John avatar [link to image]`, or from a file by typing `pk;member John avatar` and sending the message with an attached image.",
"**5**. Optionally, you may set an avatar from the URL of an image with `{prefix}member John avatar [link to image]`, or from a file by typing `{prefix}member John avatar` and sending the message with an attached image.",
"\nSee [the Getting Started guide](https://pluralkit.me/start) for more information."
})
),
@ -69,7 +69,7 @@ public class Help
$"React with {Emojis.Error} on a proxied message to delete it (only if you sent it!)",
$"React with {Emojis.RedQuestion} on a proxied message to look up information about it (like who sent it)",
$"React with {Emojis.Bell} on a proxied message to \"ping\" the sender",
"Type **`pk;invite`** to get a link to invite this bot to your own server!"
"Type **`{prefix}invite`** to get a link to invite this bot to your own server!"
})
),
}
@ -82,9 +82,9 @@ public class Help
(
"More information",
String.Join("\n", new[] {
"For a full list of commands, see [the command list](https://pluralkit.me/commands), or type `pk;commands`.",
"For a full list of commands, see [the command list](https://pluralkit.me/commands), or type `{prefix}commands`.",
"For a more in-depth explanation of message proxying, see [the documentation](https://pluralkit.me/guide#proxying).",
"If you're an existing user of Tupperbox, type `pk;import` and attach a Tupperbox export file (from `tul!export`) to import your data from there.",
"If you're an existing user of Tupperbox, type `{prefix}import` and attach a Tupperbox export file (from `tul!export`) to import your data from there.",
"We also have a [web dashboard](https://dash.pluralkit.me) to edit your system info online."
})
),
@ -142,11 +142,11 @@ public class Help
=> ctx.Rest.CreateMessage(ctx.Channel.Id, new MessageRequest
{
Content = $"{Emojis.Warn} If you cannot see the rest of this message see [the FAQ](<https://pluralkit.me/faq/#why-do-most-of-pluralkit-s-messages-look-blank-or-empty>)",
Embeds = new[] { helpEmbed with { Description = Help.Description } },
Embeds = new[] { helpEmbed with { Description = Help.Description.Replace("{prefix}", ctx.DefaultPrefix) } },
Components = new[] { helpPageButtons(ctx.Author.Id) },
});
public static Task ButtonClick(InteractionContext ctx)
public static Task ButtonClick(InteractionContext ctx, string prefix)
{
if (!ctx.CustomId.Contains(ctx.User.Id.ToString()))
return ctx.Ignore();
@ -156,7 +156,7 @@ public class Help
if (ctx.Event.Message.Components.First().Components.Where(x => x.CustomId == ctx.CustomId).First().Style == ButtonStyle.Primary)
return ctx.Respond(InteractionResponse.ResponseType.UpdateMessage, new()
{
Embeds = new[] { helpEmbed with { Description = Help.Description } },
Embeds = new[] { helpEmbed with { Description = Help.Description.Replace("{prefix}", prefix) } },
Components = new[] { buttons }
});
@ -164,7 +164,8 @@ public class Help
return ctx.Respond(InteractionResponse.ResponseType.UpdateMessage, new()
{
Embeds = new[] { helpEmbed with { Fields = helpEmbedPages.GetValueOrDefault(ctx.CustomId.Split("-")[2]) } },
Embeds = new[] { helpEmbed with { Fields = helpEmbedPages.GetValueOrDefault(ctx.CustomId.Split("-")[2]).Select((item, index) =>
new Embed.Field(item.Name.Replace("{prefix}", prefix), item.Value.Replace("{prefix}", prefix))).ToArray() } },
Components = new[] { buttons }
});
}