Added required parameter to GetService
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public static class CommandExtensions
|
||||
{
|
||||
public static CommandService Commands(this DiscordClient client)
|
||||
=> client.GetService<CommandService>();
|
||||
public static CommandService Commands(this DiscordClient client, bool required = true)
|
||||
=> client.GetService<CommandService>(required);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace Discord.Commands.Permissions.Levels
|
||||
namespace Discord.Commands.Permissions.Levels
|
||||
{
|
||||
public class PermissionLevelChecker : IPermissionChecker
|
||||
{
|
||||
@@ -12,10 +10,8 @@ namespace Discord.Commands.Permissions.Levels
|
||||
|
||||
internal PermissionLevelChecker(DiscordClient client, int minPermissions)
|
||||
{
|
||||
_service = client.GetService<PermissionLevelService>();
|
||||
_service = client.GetService<PermissionLevelService>(true);
|
||||
_minPermissions = minPermissions;
|
||||
if (_service == null)
|
||||
throw new InvalidOperationException($"{nameof(PermissionLevelService)} must be added to {nameof(DiscordClient)} before this function is called.");
|
||||
}
|
||||
|
||||
public bool CanRun(Command command, User user, Channel channel)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace Discord.Commands.Permissions.Userlist
|
||||
namespace Discord.Commands.Permissions.Userlist
|
||||
{
|
||||
public class BlacklistChecker : IPermissionChecker
|
||||
{
|
||||
@@ -8,9 +6,7 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
|
||||
internal BlacklistChecker(DiscordClient client)
|
||||
{
|
||||
_service = client.GetService<BlacklistService>();
|
||||
if (_service == null)
|
||||
throw new InvalidOperationException($"{nameof(BlacklistService)} must be added to {nameof(DiscordClient)} before this function is called.");
|
||||
_service = client.GetService<BlacklistService>(true);
|
||||
}
|
||||
|
||||
public bool CanRun(Command command, User user, Channel channel)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace Discord.Commands.Permissions.Userlist
|
||||
namespace Discord.Commands.Permissions.Userlist
|
||||
{
|
||||
public class WhitelistChecker : IPermissionChecker
|
||||
{
|
||||
@@ -8,9 +6,7 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
|
||||
internal WhitelistChecker(DiscordClient client)
|
||||
{
|
||||
_service = client.GetService<WhitelistService>();
|
||||
if (_service == null)
|
||||
throw new InvalidOperationException($"{nameof(WhitelistService)} must be added to {nameof(DiscordClient)} before this function is called.");
|
||||
_service = client.GetService<WhitelistService>(true);
|
||||
}
|
||||
|
||||
public bool CanRun(Command command, User user, Channel channel)
|
||||
|
||||
Reference in New Issue
Block a user