cs-codex-dist-tests/Tools/BiblioTech/Options/UserOption.cs

22 lines
626 B
C#
Raw Normal View History

2023-10-22 08:10:52 +00:00
using Discord;
2023-10-24 13:25:45 +00:00
namespace BiblioTech.Options
2023-10-22 08:10:52 +00:00
{
public class UserOption : CommandOption
{
public UserOption(string description, bool isRequired)
: base("user", description, ApplicationCommandOptionType.User, isRequired)
{
}
2023-10-24 13:25:45 +00:00
public ulong? GetOptionUserId(CommandContext context)
2023-10-22 08:10:52 +00:00
{
2023-10-24 13:25:45 +00:00
var userOptionData = context.Options.SingleOrDefault(o => o.Name == Name);
2023-10-22 08:10:52 +00:00
if (userOptionData == null) return null;
var user = userOptionData.Value as IUser;
if (user == null) return null;
return user.Id;
}
}
}