2022-08-21 07:34:11 +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;
|
|
|
|
|
|
|
|
|
|
public class RemoveStaffCommand : ApplicationCommandModule
|
2022-02-21 08:40:09 +00:00
|
|
|
|
{
|
2024-10-29 09:10:37 +00:00
|
|
|
|
[SlashRequireGuild]
|
|
|
|
|
[SlashCommand("removestaff", "Removes a staff member.")]
|
|
|
|
|
public async Task OnExecute(InteractionContext command, [Option("User", "User to remove from staff.")] DiscordUser user)
|
|
|
|
|
{
|
|
|
|
|
if (!Database.IsStaff(user.Id))
|
|
|
|
|
{
|
|
|
|
|
await command.CreateResponseAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "User is already not registered as staff."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
await using MySqlConnection c = Database.GetConnection();
|
|
|
|
|
c.Open();
|
|
|
|
|
MySqlCommand deletion = new MySqlCommand(@"DELETE FROM staff WHERE user_id=@user_id", c);
|
|
|
|
|
deletion.Parameters.AddWithValue("@user_id", user.Id);
|
|
|
|
|
deletion.Prepare();
|
|
|
|
|
deletion.ExecuteNonQuery();
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
await command.CreateResponseAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = "User was removed from staff."
|
|
|
|
|
}, true);
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
// Log it if the log channel exists
|
|
|
|
|
DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
|
|
|
|
|
if (logChannel != null)
|
|
|
|
|
{
|
|
|
|
|
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = "User was removed from staff.\n"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
}
|