summaryrefslogtreecommitdiff
path: root/DiscoBot/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/Commands')
-rw-r--r--DiscoBot/Commands/CommandExtension.cs119
-rw-r--r--DiscoBot/Commands/FileHandler.cs3
-rw-r--r--DiscoBot/Commands/Gm.cs5
-rw-r--r--DiscoBot/Commands/HeldList.cs2
-rw-r--r--DiscoBot/Commands/Help.cs5
-rw-r--r--DiscoBot/Commands/LebenUndAstral.cs5
-rw-r--r--DiscoBot/Commands/List.cs2
-rw-r--r--DiscoBot/Commands/NpcCommands.cs4
-rw-r--r--DiscoBot/Commands/ProbenTest.cs12
9 files changed, 140 insertions, 17 deletions
diff --git a/DiscoBot/Commands/CommandExtension.cs b/DiscoBot/Commands/CommandExtension.cs
new file mode 100644
index 0000000..098e35f
--- /dev/null
+++ b/DiscoBot/Commands/CommandExtension.cs
@@ -0,0 +1,119 @@
+namespace DiscoBot.Auxiliary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Net;
+ using System.Text;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ using Discord;
+ using Discord.Commands;
+
+ public static class CommandExtension
+ {
+ private static WebClient client;
+
+ public static async Task ReplyTimedAsync(this ModuleBase m, string message, TimeSpan time)
+ {
+ var token = message.GetHashCode();
+ var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```", false);
+
+ var barInvoker = new BackgroundWorker();
+ barInvoker.DoWork += delegate
+ {
+ Thread.Sleep(time);
+ Delete(token, m);
+ };
+
+ await send;
+ barInvoker.RunWorkerAsync();
+ }
+
+ private static void Delete(int token, ModuleBase m)
+ {
+ var messagesAsync = m.Context.Channel.GetMessagesAsync();
+ Task.WaitAll(messagesAsync.ToArray());
+ var list = messagesAsync.ToEnumerable().ToList();
+ var messages = new List<IMessage>();
+ foreach (var task in list)
+ {
+ messages.AddRange(task.ToList());
+ }
+
+ var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c=>c );
+ var waiters = new List<Task>();
+ foreach (var message in test)
+ {
+ waiters.Add((message as IUserMessage).DeleteAsync());
+ }
+ Task.WaitAll(waiters.ToArray());
+ }
+
+ public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, bool directMessage = false)
+ {
+ var sb = new StringBuilder();
+ foreach (string re in message)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+ if (directMessage)
+ {
+ await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
+ }
+ else
+ {
+ await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
+ }
+
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ if (directMessage)
+ {
+ await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
+ }
+ else
+ {
+ await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
+ }
+ }
+
+ public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, TimeSpan time)
+ {
+ var sb = new StringBuilder();
+ foreach (string re in message)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+
+ await m.ReplyTimedAsync(sb.ToString(), time);
+
+
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ }
+
+ public static async Task SendWebFile(this IMessageChannel channel, string url = "https://i.imgur.com/0iHEycJ.png")
+ {
+ if (client == null)
+ {
+ client = new WebClient();
+ }
+
+ Stream stream = client.OpenRead(url);
+ await channel.SendFileAsync(stream, url.Split('/').Last());
+ }
+ }
+}
diff --git a/DiscoBot/Commands/FileHandler.cs b/DiscoBot/Commands/FileHandler.cs
index 52c8476..0b87b15 100644
--- a/DiscoBot/Commands/FileHandler.cs
+++ b/DiscoBot/Commands/FileHandler.cs
@@ -9,10 +9,11 @@
using DiscoBot.DSA_Game.Characters;
using Discord.Commands;
+ using DSALib;
public class FileHandler : ModuleBase
{
- [Command("send"), Summary("fügt Helden hinzu")]
+ //[Command("send"), Summary("fügt Helden hinzu")]
public async Task AddChar()
{
var msg = this.Context.Message;
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
index 540682c..483e9d2 100644
--- a/DiscoBot/Commands/Gm.cs
+++ b/DiscoBot/Commands/Gm.cs
@@ -9,11 +9,12 @@ namespace DiscoBot.Commands
using DiscoBot.DSA_Game;
using Discord.Commands;
+ using DSALib.Characters;
public class Iam : ModuleBase
{
- [Command("Iam"), Summary("Wechselt den Character")]
+ //[Command("Iam"), Summary("Wechselt den Character")]
[Alias("iam", "I_am", "i_am", "IchBin", "ichbin", "Ichbin", "Ich_bin", "ich_bin", "Ich", "ich", "I", "i")]
public Task Change_Character(params string[] givenName) // use fancy parameters
{
@@ -79,7 +80,7 @@ namespace DiscoBot.Commands
return $"{name} verwendet {waffe}";
}
- [Command("gm"), Summary("Führt eine probe aus")]
+ //[Command("gm"), Summary("Führt eine probe aus")]
[Alias("GM", "as", "As", "als")]
public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string cmdText = "", int modifier = 0)
{
diff --git a/DiscoBot/Commands/HeldList.cs b/DiscoBot/Commands/HeldList.cs
index ab4e794..a8f26e0 100644
--- a/DiscoBot/Commands/HeldList.cs
+++ b/DiscoBot/Commands/HeldList.cs
@@ -15,7 +15,7 @@
public class Held : ModuleBase
{
- [Command("held"), Summary("gibt Heldenwerte aus")]
+ //[Command("held"), Summary("gibt Heldenwerte aus")]
[Alias("Held", "Wert", "Werte", "werte", "char", "Char")]
public async Task ListAsync([Summary("Werte")] params string[] prop_list)
{
diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs
index aa168fc..4c378c9 100644
--- a/DiscoBot/Commands/Help.cs
+++ b/DiscoBot/Commands/Help.cs
@@ -67,8 +67,9 @@ namespace DiscoBot.Commands
}
return res;
}
+/*
- [Command("help"), Summary("prints the help menu.")]
+ //[Command("help"), Summary("prints the help menu.")]
[Alias("Help", "man", "Man", "Hilfe", "hilfe", "h")]
public async Task ShowHelpAsync(params string[] command_list)
{
@@ -93,6 +94,6 @@ namespace DiscoBot.Commands
//await this.ReplyAsync("```xl\n" + com.GetDescription() + "\n```");
await this.ReplyAsync("```xl\n" + Get_Specific_Help(command) + "\n```");
- }
+ }*/
}
}
diff --git a/DiscoBot/Commands/LebenUndAstral.cs b/DiscoBot/Commands/LebenUndAstral.cs
index 2b5e8f1..2406c70 100644
--- a/DiscoBot/Commands/LebenUndAstral.cs
+++ b/DiscoBot/Commands/LebenUndAstral.cs
@@ -9,10 +9,11 @@
using DiscoBot.DSA_Game.Characters;
using Discord.Commands;
+ using DSALib.Characters;
public class LE : ModuleBase
{
- [Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
+ //[Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
[Alias("le", "leben", "LP", "lp", "Le", "Lp")]
public async Task LEAsync([Summary("LE Modifier")] string prop = "", string s = "")
@@ -40,7 +41,7 @@
public class AE : ModuleBase
{
- [Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
+ //[Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
[Alias("ae", "astral", "ASP", "Asp", "asp", "Astral")]
public async Task AEAsync([Summary("AE Modifier")] string prop = "", string s = "")
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
index a251183..e77362e 100644
--- a/DiscoBot/Commands/List.cs
+++ b/DiscoBot/Commands/List.cs
@@ -15,7 +15,7 @@
public class List : ModuleBase
{
- [Command("list"), Summary("gibt eine Auflistung aus")]
+ //[Command("list"), Summary("gibt eine Auflistung aus")]
public async Task ListAsync([Summary("Aktion")] string prop)
{
var res = new List<string>();
diff --git a/DiscoBot/Commands/NpcCommands.cs b/DiscoBot/Commands/NpcCommands.cs
index 98f4589..b314494 100644
--- a/DiscoBot/Commands/NpcCommands.cs
+++ b/DiscoBot/Commands/NpcCommands.cs
@@ -13,7 +13,7 @@
public class NpcCommands : ModuleBase
{
- [Command("npc"), Summary("Erstellt ein NPC")]
+ //[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)
{
@@ -21,7 +21,7 @@
return this.ReplyAsync($"{npcName} wurde zufällig generiert");
}
- [Command("npc"), Summary("Erstellt ein NPC")]
+ //[Command("npc"), Summary("Erstellt ein NPC")]
[Alias("Npc", "NPc", "NPC", "nPC")]
public Task CopyAsync([Summary("Create Copy")] string npcName, string source, int stDv = 1)
{
diff --git a/DiscoBot/Commands/ProbenTest.cs b/DiscoBot/Commands/ProbenTest.cs
index 9614b7c..77a10ad 100644
--- a/DiscoBot/Commands/ProbenTest.cs
+++ b/DiscoBot/Commands/ProbenTest.cs
@@ -8,7 +8,7 @@
public class ProbenTest : ModuleBase
{
- [Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
+ //[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
[Alias("T", "Talent", "talent", "versuche")]
public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
{
@@ -33,7 +33,7 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
+ //[Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
[Alias("Z", "zauber", "z")]
public Task ZauberAsync([Summary("Zaubername")] string zauber, int erschwernis = 0)
{
@@ -58,7 +58,7 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
+ //[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)
{
@@ -67,21 +67,21 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("a"), Summary("Würfelt ein Angriff")]
+ //[Command("a"), Summary("Würfelt ein Angriff")]
[Alias("A", "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.Session.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
}
- [Command("p"), Summary("Würfelt eine Parade Probe")]
+ //[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.Session.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
}
- [Command("f"), Summary("Führt eine Fernkampfprobe aus")]
+ //[Command("f"), Summary("Führt eine Fernkampfprobe aus")]
[Alias("F", "fern", "Fern", "Schuss", "schuss", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
{