49 lines
1017 B
C#
49 lines
1017 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Discord;
|
|
|
|
namespace DeukBot4.MessageHandlers.CommandHandler.RequestStructure
|
|
{
|
|
public class RequestParameter
|
|
{
|
|
private readonly string _value;
|
|
|
|
public RequestParameter(string value)
|
|
{
|
|
_value = value;
|
|
}
|
|
|
|
public int? AsInt()
|
|
{
|
|
if (int.TryParse(_value, out var i))
|
|
{
|
|
return i;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public string AsString()
|
|
{
|
|
return _value;
|
|
}
|
|
|
|
public ulong? AsUlong()
|
|
{
|
|
if (ulong.TryParse(_value, out var i))
|
|
{
|
|
return i;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public async Task<IGuildUser> AsDiscordUser(IGuild guild)
|
|
{
|
|
if (ulong.TryParse(_value, out var i))
|
|
{
|
|
return await guild.GetUserAsync(i);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
} |