diff options
author | Dennis Kobert <d-kobert@web.de> | 2017-08-22 14:14:39 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2017-08-22 14:14:39 +0200 |
commit | 90285f40e5a5a51bc51cb972963f56f630bc2792 (patch) | |
tree | f3344de1d088e5d203f67846ea8fdefecab28142 /DiscoBot/MyBot.cs | |
parent | abdb151ab34d1d5356dea59ceebb97072fd83920 (diff) |
Initial push
Diffstat (limited to 'DiscoBot/MyBot.cs')
-rw-r--r-- | DiscoBot/MyBot.cs | 113 |
1 files changed, 113 insertions, 0 deletions
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<CommandService>(); + 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); + } + } +} |