SupportChild/SupportChild/Commands/StatusCommand.cs

41 lines
1.7 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.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
2022-04-18 10:52:03 +00:00
public class StatusCommand : BaseCommandModule
{
[Command("status")]
[Cooldown(1, 5, CooldownBucketType.User)]
public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
{
// Check if the user has permission to use this command.
if (!Config.HasPermission(command.Member, "status"))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "You do not have permission to use this command."
};
await command.RespondAsync(error);
command.Client.Logger.Log(LogLevel.Information, "User tried to use the status command but did not have permission.");
return;
}
2022-02-21 08:40:09 +00:00
2022-04-18 10:52:03 +00:00
long openTickets = Database.GetNumberOfTickets();
long closedTickets = Database.GetNumberOfClosedTickets();
2022-02-21 08:40:09 +00:00
2022-04-18 10:52:03 +00:00
DiscordEmbed botInfo = new DiscordEmbedBuilder()
.WithAuthor("EmotionChild/SupportChild @ GitHub", "https://github.com/EmotionChild/SupportChild", "https://cdn.emotionchild.com/Ellie.png")
.WithTitle("Bot information")
.WithColor(DiscordColor.Cyan)
.AddField("Version:", SupportChild.GetVersion(), false)
.AddField("Open tickets:", openTickets + "", true)
.AddField("Closed tickets (1.1.0+ tickets only):", closedTickets + " ", true);
await command.RespondAsync(botInfo);
}
}
2022-05-19 11:38:59 +00:00
}