SupportChild/Commands/SummaryCommand.cs

35 lines
1.4 KiB
C#
Raw Normal View History

2022-04-18 10:52:03 +00:00
using System.Threading.Tasks;
2022-02-21 08:40:09 +00:00
using DSharpPlus.Entities;
2022-08-21 07:34:11 +00:00
using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes;
2022-02-21 08:40:09 +00:00
2022-08-21 07:34:11 +00:00
namespace SupportChild.Commands;
2022-02-21 08:40:09 +00:00
2022-08-21 07:34:11 +00:00
public class SummaryCommand : ApplicationCommandModule
{
[SlashRequireGuild]
[SlashCommand("summary", "Lists tickets assigned to a user.")]
public async Task OnExecute(InteractionContext command)
{
if (Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
{
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.CreateResponseAsync(channelInfo);
}
else
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "This channel is not a ticket."
}, true);
}
}
2022-05-19 11:38:59 +00:00
}