summaryrefslogtreecommitdiff
path: root/DiscoBot/MyBot.cs
blob: 12f5e56306adb272a40996a942c25141f5eec934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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);
        }
    }
}