From 90285f40e5a5a51bc51cb972963f56f630bc2792 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 22 Aug 2017 14:14:39 +0200 Subject: Initial push --- DiscoBot/MyBot.cs | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 DiscoBot/MyBot.cs (limited to 'DiscoBot/MyBot.cs') diff --git a/DiscoBot/MyBot.cs b/DiscoBot/MyBot.cs new file mode 100644 index 0000000..12f5e56 --- /dev/null +++ b/DiscoBot/MyBot.cs @@ -0,0 +1,113 @@ +using Discord; +using Discord.Commands; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Drawing; +using System.Windows; + +namespace DiscoBot +{ + class MyBot + { + DiscordClient discord; + CommandService commands; + private String token; + ServerControl FTB = new ServerControl(); + + public MyBot(string token = "Mjk0NTU0MDU4Nzg4NzAwMTYx.C7XGwQ.VwCAM10lDmwUe01NhBvDKNbd17I") + { + this.token = token; + + discord = new DiscordClient(x => + { + x.LogLevel = LogSeverity.Info; + x.LogHandler = Log; + }); + + discord.UsingCommands(x => + { + x.PrefixChar = '!'; + x.AllowMentionPrefix = true; + }); + + commands = discord.GetService(); + Mandelbrot(); + Server(); + DSA(); + + discord.ExecuteAndWait(async () => + { + await discord.Connect(token, TokenType.Bot); + }); + } + + private void Mandelbrot() + { + commands.CreateCommand("mandelbrot") + .Do(async (e) => + { + //await e.Channel.SendMessage("!hallo"); + + await e.Channel.SendFile(@"C:\temp\temp.png"); + + + }); + } + private void Server() + { + + commands.CreateCommand("start") + .Do(async (e) => + { + await e.Channel.SendMessage("Server wird gestartet"); + + FTB.Start(); + + }); + commands.CreateCommand("stop") + .Do(async (e) => + { + await e.Channel.SendMessage("Server wird gestoppt"); + + //FTB.Stop(); + }); + commands.CreateCommand("/") + .Parameter("command",ParameterType.Required) + .Parameter("value",ParameterType.Multiple) + .Do(async (e) => + { + await e.Channel.SendMessage("Command wird ausgeführt"); + + FTB.Command(e.GetArg("command")+" "+e.GetArg("value")); + }); + + commands.CreateCommand("restart") + .Do(async (e) => + { + await e.Channel.SendMessage("Server wird neu gestartet"); + + FTB.Stop(); + }); + + } + private void DSA() + { + commands.CreateCommand("wer ist Schuld?") + .Do(async (e) => + { + await e.Channel.SendMessage(e.Channel.Users.ToArray()[new Random().Next(0,4)].ToString()); + + FTB.Stop(); + }); + } + + private void Log(object sender, LogMessageEventArgs e) + { + Console.WriteLine(e.Message); + } + } +} -- cgit v1.2.3-70-g09d2