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

23 lines
661 B
C#
Raw Normal View History

2023-10-22 08:10:52 +00:00
using Discord;
using Discord.WebSocket;
2023-10-22 08:38:46 +00:00
namespace BiblioTech.Commands
2023-10-22 08:10:52 +00:00
{
public class UserOption : CommandOption
{
public UserOption(string description, bool isRequired)
: base("user", description, ApplicationCommandOptionType.User, isRequired)
{
}
public ulong? GetOptionUserId(SocketSlashCommand command)
{
var userOptionData = command.Data.Options.SingleOrDefault(o => o.Name == Name);
if (userOptionData == null) return null;
var user = userOptionData.Value as IUser;
if (user == null) return null;
return user.Id;
}
}
}