2024-12-26 18:36:20 +13:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using DSharpPlus.Commands;
|
|
|
|
|
using DSharpPlus.Commands.ContextChecks;
|
|
|
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
using DSharpPlus.Entities;
|
2024-12-27 01:21:37 +13:00
|
|
|
|
using DSharpPlus.Exceptions;
|
2023-03-24 01:21:20 +13:00
|
|
|
|
using MySqlConnector;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2022-08-21 19:34:11 +12:00
|
|
|
|
namespace SupportChild.Commands;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2024-12-26 18:36:20 +13:00
|
|
|
|
public class SetSummaryCommand
|
2022-08-21 19:34:11 +12:00
|
|
|
|
{
|
2024-12-26 18:36:20 +13:00
|
|
|
|
[RequireGuild]
|
|
|
|
|
[Command("setsummary")]
|
|
|
|
|
[Description("Sets a ticket's summary for the summary command.")]
|
|
|
|
|
public async Task OnExecute(SlashCommandContext command, [Parameter("Summary")][Description("The ticket summary text.")] string summary)
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
// Check if ticket exists in the database
|
2025-02-06 15:15:18 +13:00
|
|
|
|
if (!Database.Ticket.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
2024-12-26 18:36:20 +13:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "This channel is not a ticket."
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2025-02-06 15:15:18 +13:00
|
|
|
|
if (Database.Ticket.SetSummary(command.Channel.Id, summary))
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
2025-02-06 15:15:18 +13:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = "Summary set."
|
|
|
|
|
}, true);
|
2024-12-27 01:21:37 +13:00
|
|
|
|
|
2025-02-06 15:15:18 +13:00
|
|
|
|
await LogChannel.Success(command.User.Mention + " set the summary for " + command.Channel.Mention + " to:\n\n" + summary, ticket.id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "Error: Failed setting the summary of a ticket in database."
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
2024-10-29 22:10:37 +13:00
|
|
|
|
}
|
2022-05-19 23:38:59 +12:00
|
|
|
|
}
|