public override ValueTask <CheckResult> CheckAsync(object argument, DiscordGuildCommandContext context) { if (context.Guild == null) { throw new InvalidOperationException($"{GetType().Name} requires a non-null guild."); } var(targetName, target) = GetTarget(context); if (argument is IMember member) { if (GetHierarchy(context.Guild, target) > GetHierarchy(context.Guild, member)) { return(Success()); } } else { var role = argument as IRole; if (GetHierarchy(context.Guild, target) > role.Position) { return(Success()); } } return(Failure($"The provided {(argument is IMember ? "member" : "role")} must be below the {targetName} in role hierarchy.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { if (context.Author.Id == context.Guild.OwnerId) { return(Success()); } return(Failure("This can only be executed by the guild owner.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { if (context.Author.RoleIds.Any(x => x == Id)) { return(Success()); } return(Failure($"This can only be executed by members with the role ID {Id}.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { if (context.CurrentMember.RoleIds.Any(x => x == Id)) { return(Success()); } return(Failure($"The bot requires the role with ID {Id}.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { if (Id == null || Id == context.GuildId) { return(Success()); } return(Failure($"This can only be executed in the guild with the ID {Id}.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { var permissions = context.Author.GetPermissions(context.Channel); if (permissions.Has(Permissions)) { return(Success()); } return(Failure($"You lack the necessary channel permissions ({Permissions - permissions}) to execute this.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { var permissions = context.CurrentMember.GetPermissions(); if (permissions.Has(Permissions)) { return(Success()); } return(Failure($"The bot lacks the necessary guild permissions ({Permissions & ~permissions}) to execute this.")); }
public override ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context) { if (context.Channel is null) { throw new InvalidOperationException($"{nameof(RequireNsfwAttribute)} requires the context channel."); } var isNsfw = context.Channel switch { CachedTextChannel textChannel => textChannel.IsNsfw, CachedThreadChannel threadChannel => threadChannel.GetChannel()?.IsNsfw ?? false, _ => false }; if (isNsfw) { return(Success()); } return(Failure("This can only be executed in a NSFW channel.")); } }
public abstract ValueTask <CheckResult> CheckAsync(DiscordGuildCommandContext context);
protected abstract (string Name, IMember Member) GetTarget(DiscordGuildCommandContext context);
public abstract ValueTask <CheckResult> CheckAsync(object argument, DiscordGuildCommandContext context);
/// <inheritdoc cref="ParseAsync(Parameter, string, DiscordCommandContext)"/> public abstract ValueTask <TypeParserResult <T> > ParseAsync(Parameter parameter, string value, DiscordGuildCommandContext context);