summaryrefslogtreecommitdiff
path: root/DiscoBot/ToRework/Permissions.cs
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-26 23:49:26 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-26 23:49:26 +0200
commit19bf37de7642ae8cdefd8fc6b4fadac3ac96ea9b (patch)
tree08e7a9b15d806777fa1b839e897a171823649ab1 /DiscoBot/ToRework/Permissions.cs
parentb411aa2128c2724bec0ecedb8cb4e1ffa59f3b53 (diff)
ported most code to WebApiProject
everything except the user identification and file locations should be somewhat functional
Diffstat (limited to 'DiscoBot/ToRework/Permissions.cs')
-rw-r--r--DiscoBot/ToRework/Permissions.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/DiscoBot/ToRework/Permissions.cs b/DiscoBot/ToRework/Permissions.cs
new file mode 100644
index 0000000..4d73146
--- /dev/null
+++ b/DiscoBot/ToRework/Permissions.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DiscoBot.Auxiliary
+{
+ using Discord.Commands;
+ using Discord.WebSocket;
+
+ 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, string[] 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))
+ {
+ c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ return false;
+ }
+
+ return true;
+ }
+
+ public static void Test(ICommandContext c, string[] roles)
+ {
+ if (!Check(c, roles))
+ {
+ c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ }
+ }
+ }
+}