diff --git a/.gitignore b/.gitignore index 3be7c3c..e147e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ nimscan/bin .vscode server_backup old_tests -nim_bot/src/token.key \ No newline at end of file +nim_bot/src/token.key +nim_bot/src/tmp +nim_bot/src/bin \ No newline at end of file diff --git a/nim_bot/src/config.nims b/nim_bot/src/config.nims index 370eccb..3cc219e 100644 --- a/nim_bot/src/config.nims +++ b/nim_bot/src/config.nims @@ -1,2 +1,3 @@ switch("d", "ssl") -switch("d", "release") \ No newline at end of file +switch("d", "release") +switch("o", "bin/nim_bot") \ No newline at end of file diff --git a/nim_bot/src/nim_bot b/nim_bot/src/nim_bot deleted file mode 100755 index c7279c3..0000000 Binary files a/nim_bot/src/nim_bot and /dev/null differ diff --git a/nim_bot/src/nim_bot.nim b/nim_bot/src/nim_bot.nim index c283014..568b9c5 100644 --- a/nim_bot/src/nim_bot.nim +++ b/nim_bot/src/nim_bot.nim @@ -1,4 +1,4 @@ -import asyncdispatch, json, options, dimscord, strutils, harpoon, os, db_sqlite +import asyncdispatch, json, options, dimscord, strutils, harpoon, os, db_sqlite, strformat, tables from uri import parseUri discard os.execShellCmd("clear") let @@ -21,14 +21,19 @@ proc messageCreate(s: Shard, m: Message) {.event(discord).} = embeds = @[Embed( title: some "TaxenHeimer Bot", fields: some @[EmbedField( - name: "**$help**", + name: fmt"**{prefix}help**", value: "`Displays this menu`", inline: some true ), EmbedField( - name: "**$namemc**", + name: fmt"**{prefix}namemc**", value: "`Displays informations about a minecraft account`", inline: some true + ), + EmbedField( + name: fmt"**{prefix}status**", + value: "`Gives overall informations on the database`", + inline: some true )], color: some 0x000066 )] @@ -68,22 +73,22 @@ proc messageCreate(s: Shard, m: Message) {.event(discord).} = title: some "Namemc Lookup", fields: some @[EmbedField( name: "**username**", - value: "```\n" & username & "\n```", + value: fmt"```{'\n'}{username}{'\n'}```", inline: some true ), EmbedField( name: "**UUID**", - value: "```\n" & uuid & "\n```", + value: fmt"```{'\n'}{uuid}{'\n'}```", inline: some true ), EmbedField( name: "**Creation Date(Might not be given)**", - value: "```\n" & date & "\n```", + value: fmt"```{'\n'}{date}{'\n'}```", inline: some true ), EmbedField( name: "**Name History**", - value: "```fix\n" & hist & "\n```", + value: fmt"```fix{'\n'}{hist}{'\n'}```", inline: some false ) ], @@ -99,18 +104,28 @@ proc messageCreate(s: Shard, m: Message) {.event(discord).} = of "status": let db = open("../../server/servers.db", "", "", "") - server = db.getAllRows(sql"SELECT host FROM servers").len.intToStr + server = $db.getAllRows(sql"SELECT host FROM servers").len discard await discord.api.sendMessage( m.channel_id, embeds = @[Embed( title: some "**Server Database Status**", - fields: some @[EmbedField( - name: "**Total Server Count**", - value: "`" & server & "`", - inline: some false - )], + description: some fmt"```{'\n'}{server} total servers{'\n'}```", color: some 0x000066 )] ) +proc guild_member_add(s: Shard, g: Guild, m: Member) {.event(discord).} = + discard await discord.api.sendMessage( + "999502028227227810", + embeds = @[Embed( + title: some "Welcome to TaxenHeimer!", + description: some fmt"Welcome <@{m.user.id}>! Hope you'll have a great time :coffee:", + color: some 0x000066, + fields: some @[EmbedField( + name: "Member Count", + value: "```\n" & $g.members.len & "\n```" + )] + )] + ) + waitFor discord.startSession() \ No newline at end of file diff --git a/server/index.js b/server/index.js index f62b5f4..38aef7e 100644 --- a/server/index.js +++ b/server/index.js @@ -91,5 +91,5 @@ app.listen(9000, () => { console.clear() console.log("server ready") }) -process.on("unhandledRejection", callback => console.log(callback)) -process.on("uncaughtException", callback => console.log(callback)) \ No newline at end of file +process.on("unhandledRejection", callback => console.log(callback.message)) +process.on("uncaughtException", callback => console.log(callback.message)) \ No newline at end of file