summaryrefslogtreecommitdiff
path: root/DiscordBot/Rework
diff options
context:
space:
mode:
authoruzvkl <dennis.kobert@student.kit.edu>2019-05-20 00:54:14 +0200
committeruzvkl <dennis.kobert@student.kit.edu>2019-05-20 00:54:14 +0200
commited26623e17e8dfcc036f88cca6de10d5a35697ec (patch)
tree26dae8b824631e6542c876c82ce0e15260c411bc /DiscordBot/Rework
parent2ab4051c6fe720dc47e99b0c305a0d779ee02d51 (diff)
Reorganize Code delete ZoBotanica
Diffstat (limited to 'DiscordBot/Rework')
-rw-r--r--DiscordBot/Rework/Permissions.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/DiscordBot/Rework/Permissions.cs b/DiscordBot/Rework/Permissions.cs
new file mode 100644
index 0000000..119e628
--- /dev/null
+++ b/DiscordBot/Rework/Permissions.cs
@@ -0,0 +1,38 @@
+using System.Linq;
+using Discord.Commands;
+using Discord.WebSocket;
+
+namespace DiscordBot.Rework
+{
+ 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();
+ }
+ }
+ }
+}