feat: add help, invite, dashboard commands
This commit is contained in:
parent
6f002c06a5
commit
301744dd4e
3 changed files with 106 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ using System.Text.Json;
|
|||
using System.Web;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Catalogger.Backend.Services;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using Remora.Commands.Attributes;
|
||||
|
|
@ -49,12 +50,109 @@ public class MetaCommands(
|
|||
RoleCache roleCache,
|
||||
ChannelCache channelCache,
|
||||
EmojiCache emojiCache,
|
||||
IDiscordRestChannelAPI channelApi
|
||||
IDiscordRestChannelAPI channelApi,
|
||||
PermissionResolverService permissionResolver
|
||||
) : CommandGroup
|
||||
{
|
||||
private readonly ILogger _logger = logger.ForContext<MetaCommands>();
|
||||
private readonly HttpClient _client = new();
|
||||
|
||||
[Command("help")]
|
||||
[Description("Learn more about Catalogger.")]
|
||||
public async Task<IResult> HelpAsync()
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
.WithColour(DiscordUtils.Purple)
|
||||
.WithTitle("Catalogger")
|
||||
.WithDescription(
|
||||
"""
|
||||
A logging bot that integrates with PluralKit's message proxying.
|
||||
Use `/configure-channels` to get started!
|
||||
"""
|
||||
);
|
||||
|
||||
if (config.Discord.EnableDash)
|
||||
embed.Description +=
|
||||
$"\n\nYou can also use the dashboard for configuration: {config.Web.BaseUrl}";
|
||||
|
||||
embed.AddField(
|
||||
"Configuration",
|
||||
"""
|
||||
`/configure-channels`: Set which events will be logged to which channels
|
||||
`/ignored-channels`: Set which channels will be ignored entirely
|
||||
`/redirects`: Override where a channel's messages will be logged
|
||||
`/key-roles`: Set which roles are treated as key roles and are logged with more detail than others
|
||||
`/invites`: Manage invites and create new ones
|
||||
`/check-permissions`: Check for any issues with logging
|
||||
"""
|
||||
);
|
||||
|
||||
embed.AddField("Creator", "<@694563574386786314> / starshines.gay");
|
||||
embed.AddField(
|
||||
"Source code",
|
||||
"https://codeberg.org/starshine/catalogger / Licensed under the GNU AGPL v3"
|
||||
);
|
||||
|
||||
if (config.Discord.SupportGuild != null)
|
||||
embed.AddField(
|
||||
"Support",
|
||||
$"Use this link to join the support server: {config.Discord.SupportGuild}"
|
||||
);
|
||||
|
||||
return await feedbackService.ReplyAsync(
|
||||
embeds: [embed.Build().GetOrThrow()],
|
||||
isEphemeral: true
|
||||
);
|
||||
}
|
||||
|
||||
[Command("invite")]
|
||||
[Description("Get a link to invite Catalogger to your server.")]
|
||||
public async Task<IResult> InviteAsync()
|
||||
{
|
||||
var inviteUrl =
|
||||
$"https://discord.com/oauth2/authorize?client_id={config.Discord.ApplicationId}"
|
||||
+ "&permissions=537250993&scope=bot+applications.commands";
|
||||
|
||||
return await feedbackService.ReplyAsync(
|
||||
$"Use this link to invite Catalogger to your server: {inviteUrl}",
|
||||
isEphemeral: true
|
||||
);
|
||||
}
|
||||
|
||||
[Command("dashboard")]
|
||||
[Description("Get a link to the dashboard.")]
|
||||
public async Task<IResult> DashboardLinkAsync()
|
||||
{
|
||||
if (!config.Discord.EnableDash)
|
||||
return await feedbackService.ReplyAsync(
|
||||
"The dashboard is not enabled for this version of Catalogger.",
|
||||
isEphemeral: true
|
||||
);
|
||||
|
||||
if (
|
||||
contextInjection.Context?.TryGetGuildID(out var guildId) != true
|
||||
|| contextInjection.Context?.TryGetUserID(out var userId) != true
|
||||
)
|
||||
return await feedbackService.ReplyAsync(
|
||||
$"The dashboard is available here: {config.Web.BaseUrl}",
|
||||
isEphemeral: true
|
||||
);
|
||||
|
||||
var perms = await permissionResolver.GetGuildPermissionsAsync(guildId, userId);
|
||||
if (
|
||||
perms.HasPermission(DiscordPermission.ManageGuild)
|
||||
|| perms.HasPermission(DiscordPermission.Administrator)
|
||||
)
|
||||
return await feedbackService.ReplyAsync(
|
||||
$"The dashboard for this server is available here: {config.Web.BaseUrl}/dash/{guildId}"
|
||||
);
|
||||
|
||||
return await feedbackService.ReplyAsync(
|
||||
$"The dashboard is available here: {config.Web.BaseUrl}",
|
||||
isEphemeral: true
|
||||
);
|
||||
}
|
||||
|
||||
[Command("ping")]
|
||||
[Description("Ping pong! See the bot's latency")]
|
||||
public async Task<IResult> PingAsync()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue