SupportChild/Commands/SummaryCommand.cs

37 lines
1.4 KiB
C#
Raw Normal View History

using System.ComponentModel;
using System.Threading.Tasks;
using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
2022-02-21 08:40:09 +00:00
using DSharpPlus.Entities;
2022-08-21 07:34:11 +00:00
namespace SupportChild.Commands;
2022-02-21 08:40:09 +00:00
public class SummaryCommand
2022-08-21 07:34:11 +00:00
{
[RequireGuild]
[Command("summary")]
2024-12-26 12:57:41 +00:00
[Description("Shows ticket information and summary if there is one.")]
public async Task OnExecute(SlashCommandContext command)
{
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
{
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "This channel is not a ticket."
}, true);
return;
}
DiscordEmbed channelInfo = new DiscordEmbedBuilder()
.WithTitle("Channel information")
.WithColor(DiscordColor.Cyan)
.AddField("Ticket number:", ticket.id.ToString("00000"), true)
.AddField("Ticket creator:", $"<@{ticket.creatorID}>", true)
.AddField("Assigned staff:", ticket.assignedStaffID == 0 ? "Unassigned." : $"<@{ticket.assignedStaffID}>", true)
.AddField("Creation time:", ticket.DiscordRelativeTime(), true)
.AddField("Summary:", string.IsNullOrEmpty(ticket.summary) ? "No summary." : ticket.summary.Replace("\\n", "\n"));
await command.RespondAsync(channelInfo);
}
2022-05-19 11:38:59 +00:00
}