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;
|
2023-03-23 12:21:20 +00:00
|
|
|
|
using MySqlConnector;
|
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 SetSummaryCommand : ApplicationCommandModule
|
|
|
|
|
{
|
|
|
|
|
[SlashRequireGuild]
|
|
|
|
|
[SlashCommand("setsummary", "Sets a ticket's summary for the summary command.")]
|
|
|
|
|
public async Task OnExecute(InteractionContext command, [Option("Summary", "The ticket summary text.")] string summary)
|
|
|
|
|
{
|
|
|
|
|
ulong channelID = command.Channel.Id;
|
|
|
|
|
// Check if ticket exists in the database
|
|
|
|
|
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket _))
|
|
|
|
|
{
|
|
|
|
|
await command.CreateResponseAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "This channel is not a ticket."
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2022-08-21 07:34:11 +00:00
|
|
|
|
await using MySqlConnection c = Database.GetConnection();
|
|
|
|
|
c.Open();
|
|
|
|
|
MySqlCommand update = new MySqlCommand(@"UPDATE tickets SET summary = @summary WHERE channel_id = @channel_id", c);
|
|
|
|
|
update.Parameters.AddWithValue("@summary", summary);
|
|
|
|
|
update.Parameters.AddWithValue("@channel_id", channelID);
|
|
|
|
|
update.Prepare();
|
|
|
|
|
update.ExecuteNonQuery();
|
|
|
|
|
update.Dispose();
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2022-08-21 07:34:11 +00:00
|
|
|
|
await command.CreateResponseAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = "Summary set."
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
}
|