Permission chain will no longer mention people

This commit is contained in:
Kwoth 2016-10-06 20:47:13 +02:00
parent 3136560f15
commit 8b6750c5ba
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Services.Database; using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
@ -89,7 +90,7 @@ namespace NadekoBot.Modules.Permissions
return null; return null;
} }
public static string GetCommand(this Permission perm) public static string GetCommand(this Permission perm, IGuild guild = null)
{ {
var com = ""; var com = "";
switch (perm.PrimaryTarget) switch (perm.PrimaryTarget)
@ -125,7 +126,10 @@ namespace NadekoBot.Modules.Permissions
switch (perm.PrimaryTarget) switch (perm.PrimaryTarget)
{ {
case PrimaryPermissionType.User: case PrimaryPermissionType.User:
if (guild == null)
com += $"<@{perm.PrimaryTargetId}>"; com += $"<@{perm.PrimaryTargetId}>";
else
com += guild.GetUser(perm.PrimaryTargetId).ToString() ?? $"<@{perm.PrimaryTargetId}>";
break; break;
case PrimaryPermissionType.Channel: case PrimaryPermissionType.Channel:
com += $"<#{perm.PrimaryTargetId}>"; com += $"<#{perm.PrimaryTargetId}>";

View File

@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Permissions
var perms = uow.GuildConfigs.PermissionsFor(channel.Guild.Id).RootPermission; var perms = uow.GuildConfigs.PermissionsFor(channel.Guild.Id).RootPermission;
var i = 1; var i = 1;
toSend = String.Join("\n", perms.AsEnumerable().Select(p => $"`{(i++)}.` {p.GetCommand()}")); toSend = String.Join("\n", perms.AsEnumerable().Select(p => $"`{(i++)}.` {p.GetCommand(channel.Guild)}"));
} }
if (string.IsNullOrWhiteSpace(toSend)) if (string.IsNullOrWhiteSpace(toSend))