mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-11 03:27:01 +00:00
31 lines
941 B
C#
31 lines
941 B
C#
using Discord;
|
|
|
|
namespace BiblioTech.Options
|
|
{
|
|
public class FileAttachementOption : CommandOption
|
|
{
|
|
public FileAttachementOption(string name, string description, bool isRequired)
|
|
: base(name, description, type: ApplicationCommandOptionType.Attachment, isRequired)
|
|
{
|
|
}
|
|
|
|
public async Task<IAttachment?> Parse(CommandContext context)
|
|
{
|
|
var fileOptionData = context.Options.SingleOrDefault(o => o.Name == Name);
|
|
if (fileOptionData == null)
|
|
{
|
|
await context.Followup("Attachement option not received.");
|
|
return null;
|
|
}
|
|
var attachement = fileOptionData.Value as IAttachment;
|
|
if (attachement == null)
|
|
{
|
|
await context.Followup("Attachement is null or empty.");
|
|
return null;
|
|
}
|
|
|
|
return attachement;
|
|
}
|
|
}
|
|
}
|