summaryrefslogtreecommitdiff
path: root/DiscoBot/Auxiliary
diff options
context:
space:
mode:
authorKobert <Kassian.Kobert@gmail.com>2018-06-01 13:36:58 +0200
committerKobert <Kassian.Kobert@gmail.com>2018-06-01 13:36:58 +0200
commit62c71f7189b0bc3689fe6f82a8234af922cef2d2 (patch)
treea940f01d71d2e876067124cf7455c67cfed880ac /DiscoBot/Auxiliary
parentdafc59577d16eac7fb198e36c81bd3fe4b008f18 (diff)
parentf6edadbfcadbc9e38e22500a496a74dd49d96d8a (diff)
Merge branch 'master' of https://github.com/TrueDoctor/DiscoBot
Diffstat (limited to 'DiscoBot/Auxiliary')
-rw-r--r--DiscoBot/Auxiliary/CommandExtension.cs2
-rw-r--r--DiscoBot/Auxiliary/Permissions.cs40
2 files changed, 42 insertions, 0 deletions
diff --git a/DiscoBot/Auxiliary/CommandExtension.cs b/DiscoBot/Auxiliary/CommandExtension.cs
index 059ea91..5d07f6c 100644
--- a/DiscoBot/Auxiliary/CommandExtension.cs
+++ b/DiscoBot/Auxiliary/CommandExtension.cs
@@ -42,5 +42,7 @@
m.Context.Channel.DeleteMessagesAsync(
messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot));
}
+
+
}
}
diff --git a/DiscoBot/Auxiliary/Permissions.cs b/DiscoBot/Auxiliary/Permissions.cs
new file mode 100644
index 0000000..48f8040
--- /dev/null
+++ b/DiscoBot/Auxiliary/Permissions.cs
@@ -0,0 +1,40 @@
+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 void Test(ICommandContext c, string role)
+ {
+ if (!Check(c, role))
+ {
+ c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ }
+ }
+
+ public static void Test(ICommandContext c, string[] roles)
+ {
+ if (!Check(c, roles))
+ {
+ c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ }
+ }
+ }
+}