· 6 years ago · Mar 12, 2019, 12:04 AM
1using System;
2using System.Threading.Tasks;
3using Discord;
4using Discord.Commands;
5using System.Data.SQLite;
6
7
8namespace CSharp_Discord_Bot.Core.Commands
9{
10 public class HelloWorld : ModuleBase<SocketCommandContext>
11 {
12 [Command("say"), Alias("type", "output", "print"), Summary("Print whatever you want the bot to say")]
13
14 private async Task print([Remainder]string Input = null)
15 {
16 if (Input == null || Input == "")
17 {
18 await Context.Channel.SendMessageAsync("Please enter some form of text");
19
20 }
21
22 else
23 {
24 await Context.Channel.SendMessageAsync(Input);
25 }
26 }
27
28
29
30 [Command("report"), Alias("suggest"), Summary("Output a suggestion or report to a database")]
31
32 private async Task SQL([Remainder]string Input = null)
33 {
34 if (Input == null || Input == "")
35 {
36 await Context.Channel.SendMessageAsync("Please enter some form of text");
37
38 }
39
40 else
41 {
42 string CreateQuery = @"CREATE TABLE IF NOT EXISTS
43 [suggestions] (
44 [text] TEXT NOT NULL,
45 [user] VARCHAT NULL,
46 [datetime] TIME NULL";
47
48 System.Data.SQLite.SQLiteConnection.CreateFile("db.db3");
49 using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=db.db3"))
50 {
51 using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
52 {
53 conn.Open();
54 cmd.CommandText = CreateQuery;
55 cmd.ExecuteNonQuery();
56 cmd.CommandText = "INSERT INTO SUGGESTIONS(text, user) values('dont suck', 'suck')";
57 cmd.ExecuteNonQuery();
58 await Context.Channel.SendMessageAsync("succesful");
59 using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
60 {
61 while (reader.Read())
62 {
63 Console.WriteLine(reader["text"] + ":" + reader["user"]);
64
65
66 }
67 conn.Close();
68 }
69
70 }
71 }
72
73
74 }
75 }
76
77
78
79
80 /* [Command("randomfact"), Alias("fact"), Summary("Output a random fact")]
81
82 private async Task potato([Remainder]string Input = null)
83 {
84 if ()
85 } */
86
87
88
89
90 [Command("author"), Alias("embed"), Summary("Embed Test")]
91 public async Task Embed([Remainder]string Input = null)
92 {
93 EmbedBuilder Embed = new EmbedBuilder();
94 if (Input == null || Input == "") // if its empty, output without an input value box
95 {
96 Embed.WithAuthor("Test Embed", "https://cdn.discordapp.com/attachments/554283748863246338/554284091738947595/bear.png");
97 Embed.WithColor(45, 23, 97);
98 Embed.WithFooter("This is the footer - this is the owner though lol", Context.Guild.Owner.GetAvatarUrl());
99 Embed.WithDescription("This is a description im im pretty sure\n" + "[This is a good site, to make an exaple of URL embeds](https://pornhub.com)");
100 }
101 else //if its not empty, go add the input field
102 {
103 Embed.WithAuthor("Test Embed", "https://cdn.discordapp.com/attachments/554283748863246338/554284091738947595/bear.png");
104 Embed.WithColor(45, 23, 97);
105 Embed.WithFooter("This is the footer - this is the owner though lol", Context.Guild.Owner.GetAvatarUrl()); //Guids are servers
106 Embed.WithDescription("This is a description im im pretty sure\n" + "[This is a good site, to make an exaple of URL embeds](https://pornhub.com)");
107 Embed.AddField("User Input:", Input);
108 }
109
110 await Context.Channel.SendMessageAsync("", false, Embed.Build()); //output embed
111 }
112
113
114
115
116 [Command("spam"), Alias("spam"), Summary("Spam numbers forever")]
117 public async Task spam([Remainder]string Input = null)
118 {
119 int counter = 0;
120
121 for (; ; )
122 {
123 counter++;
124 await Context.Channel.SendMessageAsync(Convert.ToString(counter));
125
126 }
127 }
128
129 }
130}