From e6181c24124d97f2fbc932b8a68311e625463156 Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:05:52 +0200 Subject: Move dsa related stuff to subfolder --- dsa/DiscoBot/Auxiliary/Permissions.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dsa/DiscoBot/Auxiliary/Permissions.cs (limited to 'dsa/DiscoBot/Auxiliary/Permissions.cs') diff --git a/dsa/DiscoBot/Auxiliary/Permissions.cs b/dsa/DiscoBot/Auxiliary/Permissions.cs new file mode 100644 index 0000000..3ec4a2e --- /dev/null +++ b/dsa/DiscoBot/Auxiliary/Permissions.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using Discord.Commands; +using Discord.WebSocket; + +namespace DiscoBot.Auxiliary +{ + public static class Permissions + { + public static bool Check(ICommandContext c, string role) + { + return ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role)); + } + + public static bool Check(ICommandContext c, IEnumerable roles) + { + return roles.Any(role => ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role))); + } + + public static bool Test(ICommandContext c, string role) + { + if (Check(c, role)) return true; + c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); + return false; + } + + public static void Test(ICommandContext c, string[] roles) + { + if (!Check(c, roles)) c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); + } + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf