Perms added to custom reactions, actually commit
This commit is contained in:
parent
2d9fc9893b
commit
7704569c36
@ -23,10 +23,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Draw(int num = 1)
|
||||
{
|
||||
if (num < 1)
|
||||
num = 1;
|
||||
var cards = _allDecks.GetOrAdd(Context.Guild, (s) => new Cards());
|
||||
var images = new List<Image>();
|
||||
var cardObjects = new List<Cards.Card>();
|
||||
if (num > 5) num = 5;
|
||||
if (num > 10) num = 10;
|
||||
for (var i = 0; i < num; i++)
|
||||
{
|
||||
if (cards.CardPool.Count == 0 && i != 0)
|
||||
|
@ -8,6 +8,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Services.Permissions;
|
||||
|
||||
namespace NadekoBot.Services.CustomReactions
|
||||
{
|
||||
@ -21,12 +22,14 @@ namespace NadekoBot.Services.CustomReactions
|
||||
private readonly Logger _log;
|
||||
private readonly DbService _db;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly PermissionsService _perms;
|
||||
|
||||
public CustomReactionsService(DbService db, DiscordShardedClient client)
|
||||
public CustomReactionsService(PermissionsService perms, DbService db, DiscordShardedClient client)
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_db = db;
|
||||
_client = client;
|
||||
_perms = perms;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
using (var uow = _db.UnitOfWork)
|
||||
@ -48,9 +51,8 @@ namespace NadekoBot.Services.CustomReactions
|
||||
return null;
|
||||
|
||||
var content = umsg.Content.Trim().ToLowerInvariant();
|
||||
CustomReaction[] reactions;
|
||||
|
||||
GuildReactions.TryGetValue(channel.Guild.Id, out reactions);
|
||||
if (GuildReactions.TryGetValue(channel.Guild.Id, out CustomReaction[] reactions))
|
||||
if (reactions != null && reactions.Any())
|
||||
{
|
||||
var rs = reactions.Where(cr =>
|
||||
@ -99,19 +101,18 @@ namespace NadekoBot.Services.CustomReactions
|
||||
try
|
||||
{
|
||||
//todo permissions
|
||||
//if (guild != null)
|
||||
//{
|
||||
// PermissionCache pc = Permissions.GetCache(guild.Id);
|
||||
if (guild is SocketGuild sg)
|
||||
{
|
||||
PermissionCache pc = _perms.GetCache(guild.Id);
|
||||
|
||||
// if (!pc.Permissions.CheckPermissions(usrMsg, cr.Trigger, "ActualCustomReactions",
|
||||
// out int index))
|
||||
// {
|
||||
// var returnMsg =
|
||||
// $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(guild)}** is preventing this action.";
|
||||
// _log.Info(returnMsg);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
if (!pc.Permissions.CheckPermissions(msg, cr.Trigger, "ActualCustomReactions",
|
||||
out int index))
|
||||
{
|
||||
var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(sg)}** is preventing this action.";
|
||||
_log.Info(returnMsg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
await cr.Send(msg, _client, this).ConfigureAwait(false);
|
||||
|
||||
if (cr.AutoDeleteTrigger)
|
||||
|
Loading…
Reference in New Issue
Block a user