summaryrefslogtreecommitdiff
path: root/DiscoBot/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/Commands')
-rw-r--r--DiscoBot/Commands/CommandTypes.cs12
-rw-r--r--DiscoBot/Commands/Gm.cs103
-rw-r--r--DiscoBot/Commands/List.cs76
-rw-r--r--DiscoBot/Commands/NpcCommands.cs37
-rw-r--r--DiscoBot/Commands/Test.cs47
-rw-r--r--DiscoBot/Commands/Utility.cs32
-rw-r--r--DiscoBot/Commands/Voice.cs67
7 files changed, 374 insertions, 0 deletions
diff --git a/DiscoBot/Commands/CommandTypes.cs b/DiscoBot/Commands/CommandTypes.cs
new file mode 100644
index 0000000..4ff0814
--- /dev/null
+++ b/DiscoBot/Commands/CommandTypes.cs
@@ -0,0 +1,12 @@
+namespace DiscoBot.Commands
+{
+ public enum CommandTypes
+ {
+ Talent,
+ Eigenschaft,
+ Angriff,
+ Parade,
+ Fernkampf,
+ KeinChar
+ }
+}
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
new file mode 100644
index 0000000..60b82fb
--- /dev/null
+++ b/DiscoBot/Commands/Gm.cs
@@ -0,0 +1,103 @@
+namespace DiscoBot.Commands
+{
+ using System.Linq;
+ using System.Threading.Tasks;
+
+ using DiscoBot.Auxiliary;
+
+ using Discord.Commands;
+ using Discord.WebSocket;
+
+ public class Gm : ModuleBase
+ {
+ public static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
+ {
+ var comp = new SpellCorrect();
+ var chr = Dsa.Chars.OrderBy(x => comp.Compare(x.Name, name)).First();
+ switch (command)
+ {
+ case CommandTypes.Talent:
+ return chr.TestTalent(waffe, erschwernis);
+ case CommandTypes.Eigenschaft:
+ return chr.TestEigenschaft(waffe, erschwernis);
+ case CommandTypes.Angriff:
+ return chr.Angriff(waffe, erschwernis);
+ case CommandTypes.Parade:
+ return chr.Parade(waffe, erschwernis);
+ case CommandTypes.Fernkampf:
+ return chr.Fernkampf(waffe, erschwernis);
+ }
+
+ return $"{name} verwendet {waffe}";
+ }
+
+ [Command("gm"), Summary("Führt eine probe aus")]
+ [Alias("GM", "as", "As", "als")]
+ public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string waffe, int erschwernis = 0)
+ {
+ if (!((SocketGuildUser)this.Context.User).Roles.ToList().Exists(v => v.Name.Equals("Meister")))
+ {
+ await this.ReplyAsync("```xl\n Keine ausreichenden Berechtigunen\n```");
+ return;
+ }
+
+ command = command.ToLower();
+ string res = this.Test(name, command, waffe, erschwernis);
+
+ if (Dsa.GeneralContext != null && Dsa.GeneralContext.Channel.Id != this.Context.Channel.Id)
+ {
+ await Dsa.GeneralContext.Channel.SendMessageAsync("```xl\n" + res + "\n```");
+ }
+
+ await this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ private string Test(string name, string command, string waffe, int erschwernis = 0)
+ {
+ string res;
+ switch (command)
+ {
+ case "f":
+ case "fern":
+ case "fernkampf":
+ res = CheckCommand(name, CommandTypes.Fernkampf, waffe, erschwernis);
+ break;
+ case "t":
+ case "ta":
+ case "talent":
+ case "talente":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "e":
+ case "ei":
+ case "eigenschaft":
+ res = CheckCommand(name, CommandTypes.Eigenschaft, waffe, erschwernis);
+ break;
+ case "z":
+ case "za":
+ case "zauber":
+ case "magie":
+ case "m":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "a":
+ case "at":
+ case "an":
+ case "angrif":
+ case "angriff":
+ res = CheckCommand(name, CommandTypes.Angriff, waffe, erschwernis);
+ break;
+ case "p":
+ case "pa":
+ case "parade":
+ res = CheckCommand(name, CommandTypes.Parade, waffe, erschwernis);
+ break;
+ default:
+ res = $"Kommando {command} nicht gefunden";
+ break;
+ }
+
+ return res;
+ }
+ }
+}
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
new file mode 100644
index 0000000..9eac3a1
--- /dev/null
+++ b/DiscoBot/Commands/List.cs
@@ -0,0 +1,76 @@
+namespace DiscoBot.Commands
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+
+ using DiscoBot.Auxiliary;
+ using DiscoBot.Characters;
+
+ using Discord.Commands;
+
+ public class List : ModuleBase
+ {
+ [Command("list"), Summary("gibt eine Auflistung aus")]
+ public async Task ListAsync([Summary("Aktion")] string prop)
+ {
+ var res = new List<string>();
+ switch (prop.ToLower())
+ {
+ case "chars":
+ case "Chars":
+ res.AddRange(Dsa.Chars.Select(x => x.Name));
+ break;
+ case "t":
+ case "ta":
+ case "talent":
+ case "zauber":
+ res.AddRange(
+ ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])))
+ .Talente.Select(s => s.Name + "\t " + s.Value + "\t " + s.Probe));
+ break;
+ case "w":
+ case "waffe":
+ case "waffen":
+ res.AddRange(
+ ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])))
+ .Kampftalente.Select(s => s.Name));
+ break;
+ case "fern":
+ res.AddRange(
+ ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])))
+ .Talente.Select(s => s.Name));
+ break;
+ case "v":
+ case "vt":
+ case "vor":
+ case "vorteil":
+ res.AddRange(
+ ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])))
+ .Vorteile
+ .Select(s => s.Name + "\t " + (s.Value == 0 ? string.Empty : s.Value.ToString())));
+ break;
+
+ default:
+ res.Add($"Kommando {prop} nicht gefunden");
+ break;
+ }
+
+ var sb = new StringBuilder();
+ foreach (string re in res)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+ await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ }
+ }
+}
diff --git a/DiscoBot/Commands/NpcCommands.cs b/DiscoBot/Commands/NpcCommands.cs
new file mode 100644
index 0000000..f2b17b6
--- /dev/null
+++ b/DiscoBot/Commands/NpcCommands.cs
@@ -0,0 +1,37 @@
+namespace DiscoBot.Commands
+{
+ using System;
+ using System.Linq;
+ using System.Threading.Tasks;
+
+ using DiscoBot.Auxiliary;
+ using DiscoBot.Characters;
+
+ using Discord.Commands;
+
+ public class NpcCommands : ModuleBase
+ {
+ [Command("npc"), Summary("Erstellt ein NPC")]
+ [Alias("Npc", "NPc", "NPC", "nPC")]
+ public Task RandomAsync([Summary("Create Random")] string npcName, int mean = 9, int stDv = 1)
+ {
+ Dsa.Chars.Add(new Npc(npcName, mean, stDv));
+ return this.ReplyAsync($"{npcName} wurde zufällig generiert");
+ }
+
+ [Command("npc"), Summary("Erstellt ein NPC")]
+ [Alias("Npc", "NPc", "NPC", "nPC")]
+ public Task CopyAsync([Summary("Create Copy")] string npcName, string source, int stDv = 1)
+ {
+ if (Dsa.Chars.Exists(x => x.Name.Equals(npcName)))
+ {
+ throw new Exception("Char gibt es schon");
+ }
+
+ var comp = new SpellCorrect();
+ var chr = Dsa.Chars.OrderBy(x => comp.Compare(x.Name, source)).First();
+ Dsa.Chars.Add(new Character(chr as Character, npcName, stDv));
+ return this.ReplyAsync($"{npcName} wurde als variierte Kopie von {source} erstellt");
+ }
+ }
+}
diff --git a/DiscoBot/Commands/Test.cs b/DiscoBot/Commands/Test.cs
new file mode 100644
index 0000000..d56a43c
--- /dev/null
+++ b/DiscoBot/Commands/Test.cs
@@ -0,0 +1,47 @@
+namespace DiscoBot.Commands
+{
+ using System.Threading.Tasks;
+
+ using Discord.Commands;
+
+ public class Test : ModuleBase
+ {
+ [Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
+ [Alias("T", "Talent", "talent", "zauber", "z", "versuche")]
+ public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
+ {
+ string res = Gm.CheckCommand(Dsa.Relation[this.Context.User.Username], CommandTypes.Talent, talent, erschwernis);
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ [Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
+ [Alias("E", "Eigenschaft", "eigenschaft", "eigen")]
+ public Task EigenschaftAsync([Summary("Eigenschaftskürzel und Erschwernis")] string talent, int erschwernis = 0)
+ {
+ var chr = Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username]));
+ string res = chr.TestEigenschaft(talent, erschwernis);
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ [Command("a"), Summary("Würfelt ein Angriff")]
+ [Alias("At", "at", "Angriff", "angriff", "attackiere_mit", "attacke", "Attacke")]
+ public Task AngriffAsync([Summary("Weapon")] string weapon, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
+ }
+
+ [Command("p"), Summary("Würfelt eine Parade Probe")]
+ [Alias("P", "Parade", "parade", "pariere_mit")]
+ public Task ParadeAsync([Summary("Parade Weapon")] string talent, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
+ }
+
+ [Command("f"), Summary("Führt eine Fernkampfprobe aus")]
+ [Alias("F", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
+ public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])).Fernkampf(waffe, erschwernis) + "\n```");
+ }
+ }
+}
diff --git a/DiscoBot/Commands/Utility.cs b/DiscoBot/Commands/Utility.cs
new file mode 100644
index 0000000..bbba1a1
--- /dev/null
+++ b/DiscoBot/Commands/Utility.cs
@@ -0,0 +1,32 @@
+namespace DiscoBot.Commands
+{
+ using System.Threading.Tasks;
+
+ using DiscoBot.Auxiliary;
+
+ using Discord.Commands;
+
+ public class Utility : ModuleBase
+ {
+ [Command("r"), Summary("Würfelt ")]
+ [Alias("R", "Roll", "roll", "Würfle")]
+ public Task RollAsync([Remainder, Summary("Weapon")] string roll)
+ {
+ return this.ReplyAsync("```xl\n" + Misc.Roll(roll) + "\n```");
+ }
+
+ [Command("general"), Summary("Set General ")]
+ public Task SetGeneralAsync([Remainder, Summary("Set General")] int i = 0)
+ {
+ Dsa.GeneralContext = this.Context;
+ return this.Context.Channel.SendMessageAsync($"```xl\n Der Dachs hat in '{this.Context.Channel.Name}' ein Zuhause gefunden. Gm Nachrichten werden nun auch in diesem Channel gepostet. \n```");
+ }
+
+ [Command("say"), Summary("Echos a message.")]
+ [Alias("s")]
+ public Task SayAsync([Remainder, Summary("The text to echo")] string echo)
+ {
+ return this.ReplyAsync(echo);
+ }
+ }
+}
diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs
new file mode 100644
index 0000000..72988d4
--- /dev/null
+++ b/DiscoBot/Commands/Voice.cs
@@ -0,0 +1,67 @@
+namespace DiscoBot.Commands
+{
+ using System.Diagnostics;
+ using System.Threading.Tasks;
+
+ using Discord;
+ using Discord.Audio;
+ using Discord.Commands;
+
+ public class Voice : ModuleBase
+ {
+ public static IAudioClient Client { get; set; }
+ [Command("join", RunMode = RunMode.Async)]
+ public async Task JoinChannelAsync(IVoiceChannel channel = null)
+ {
+ var msg = this.Context.Message;
+
+ // Get the audio channel
+ channel = channel ?? (msg.Author as IGuildUser)?.VoiceChannel;
+ if (channel == null)
+ {
+ await msg.Channel.SendMessageAsync(
+ "User must be in a voice channel, or a voice channel must be passed as an argument.");
+ return;
+ }
+
+ // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
+ var audioClient = await channel.ConnectAsync();
+ Client = audioClient;
+ }
+
+ [Command("leave", RunMode = RunMode.Async)]
+ public Task LeaveChannelAsync(IVoiceChannel channel = null)
+ {
+ // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
+ return Client.StopAsync();
+ }
+
+ [Command("play")]
+ public Task PlayAudioAsync(string path)
+ {
+ return this.SendAsync(Client, path);
+ }
+
+ private Process CreateStream(string path)
+ {
+ var ffmpeg = new ProcessStartInfo
+ {
+ FileName = "ffmpeg",
+ Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 -ab 620000 pipe:1",
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ };
+ return Process.Start(ffmpeg);
+ }
+
+ private async Task SendAsync(IAudioClient client, string path)
+ {
+ // Create FFmpeg using the previous example
+ var ffmpeg = this.CreateStream(path);
+ var output = ffmpeg.StandardOutput.BaseStream;
+ var discord = client.CreatePCMStream(AudioApplication.Music);
+ await output.CopyToAsync(discord);
+ await discord.FlushAsync();
+ }
+ }
+}