2019-03-17 18:32:56 +01:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Discord.Commands;
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib.CommandPreconditions
|
|
|
|
{
|
2020-02-08 15:58:17 +01:00
|
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
|
2019-03-17 18:32:56 +01:00
|
|
|
public class DisableInDirectMessageAttribute : PreconditionAttribute
|
|
|
|
{
|
|
|
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
|
|
|
{
|
|
|
|
var result = context.Guild.Id != 0 ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Command unavailable in Direct Messaging");
|
|
|
|
return Task.FromResult(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|