NadekoBot/NadekoBot.Core/Common/Shard0Precondition.cs

20 lines
618 B
C#
Raw Normal View History

2017-07-17 19:42:36 +00:00
using System;
2017-06-21 13:14:08 +00:00
using System.Threading.Tasks;
2017-07-17 19:42:36 +00:00
using Discord.Commands;
using Discord.WebSocket;
2017-06-21 13:14:08 +00:00
2017-07-17 19:42:36 +00:00
namespace NadekoBot.Common
2017-06-21 13:14:08 +00:00
{
public class Shard0Precondition : PreconditionAttribute
{
public override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
{
var c = (DiscordSocketClient)context.Client;
2017-07-17 19:42:36 +00:00
if (c.ShardId != 0)
2017-06-21 13:14:08 +00:00
return Task.FromResult(PreconditionResult.FromError("Must be ran from shard #0"));
2017-07-17 19:42:36 +00:00
return Task.FromResult(PreconditionResult.FromSuccess());
2017-06-21 13:14:08 +00:00
}
}
}