]> git.taranathan.com Git - moo-bot.git/commitdiff
functions
authorTaran Nathan <moogoesmeow123@gmail.com>
Sun, 23 Aug 2026 21:26:37 +0000 (14:26 -0700)
committerTaran Nathan <moogoesmeow123@gmail.com>
Sun, 23 Aug 2026 21:26:46 +0000 (14:26 -0700)
.gitignore [new file with mode: 0644]
bot.nimble [new file with mode: 0644]
config.nims [new file with mode: 0644]
nimble.paths [new file with mode: 0644]
src/bot.nim [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..17ea45d
--- /dev/null
@@ -0,0 +1,2 @@
+bot
+.env
diff --git a/bot.nimble b/bot.nimble
new file mode 100644 (file)
index 0000000..c13f43e
--- /dev/null
@@ -0,0 +1,18 @@
+# Package
+
+version       = "0.1.0"
+author        = "moo"
+description   = "discord bot for ketchup club"
+license       = "GPL-2.0-or-later"
+srcDir        = "src"
+bin           = @["bot"]
+
+
+# Dependencies
+
+requires "nim >= 2.2.10"
+requires "json_serialization"
+requires "dimscord"
+
+requires "random >= 0.5.7"
+requires "dotenv >= 2.0.0"
diff --git a/config.nims b/config.nims
new file mode 100644 (file)
index 0000000..8ee48d2
--- /dev/null
@@ -0,0 +1,4 @@
+# begin Nimble config (version 2)
+when withDir(thisDir(), system.fileExists("nimble.paths")):
+  include "nimble.paths"
+# end Nimble config
diff --git a/nimble.paths b/nimble.paths
new file mode 100644 (file)
index 0000000..ce57736
--- /dev/null
@@ -0,0 +1,20 @@
+--noNimblePath
+--path:"/home/moo/.nimble/pkgs2/dotenv-2.0.2-1e70fc63c286ca3da7592d61dbe501fcea35bc72"
+--path:"/home/moo/.nimble/pkgs2/serialization-0.5.3-c087d26c50da40436599163888532660d6f9e631"
+--path:"/home/moo/.nimble/pkgs2/unicodedb-0.13.2-739102d885d99bb4571b1955f5f12aee423c935b"
+--path:"/home/moo/.nimble/pkgs2/dimscord-1.8.0-ea3dd7aabde21b532afb6d3f4c5e6bb159adc7bc"
+--path:"/home/moo/.nimble/pkgs2/zippy-0.10.20-fae5430d597432ea2916a6d45dee53542784d51e"
+--path:"/home/moo/.nimble/pkgs2/random-0.5.7-a848bbc060f57e69820d40c6f9b26bac296dd106"
+--path:"/home/moo/.nimble/pkgs2/results-0.5.1-a9c011f74bc9ed5c91103917b9f382b12e82a9e7"
+--path:"/home/moo/.nimble/pkgs2/jsony-1.1.6-b28964a93a3cf7248126ba39047593cd63a3aa6d"
+--path:"/home/moo/.nimble/pkgs2/json_serialization-0.4.4-8b3115354104858a0ac9019356fb29720529c2bd"
+--path:"/home/moo/.nimble/pkgs2/etf-0.1.0-a82dc298daccb2c0bec6ee1c004faac54aeec5c3/src"
+--path:"/home/moo/Projects/Nim/bot/src"
+--path:"/home/moo/.nimble/pkgs2/stew-0.5.1-46b1ef3b95b3deaedf4cc02cb3b07e3b0ee840fa"
+--path:"/home/moo/.nimble/pkgs2/faststreams-0.5.1-969ceb3666e807db8fe5c8df63466749822367a9"
+--path:"/home/moo/.nimble/pkgs2/libsodium-0.6.0-a2bcc3d783446e393eacf5759dda821f0f714796"
+--path:"/home/moo/.nimble/pkgs2/ws-0.6.0-b854365c3c985dc6be7cf36337aa0d4dce7e1f33"
+--path:"/home/moo/.nimble/pkgs2/flatty-0.4.0-2105eef6c8aa1bd84bf92ace7fbad63c0110c82a"
+--path:"/home/moo/.nimble/pkgs2/unittest2-0.2.5-02bb3751ba9ddc3c17bfd89f2e41cb6bfb8fc0c9"
+--path:"/home/moo/.nimble/pkgs2/opussum-0.6.3-dbca84e4b7e6d3d80c8f669b45851869f37f59c9"
+--path:"/home/moo/.nimble/pkgs2/regex-0.26.3-4d24e7d7441137cd202e16f2359a5807ddbdc31f"
diff --git a/src/bot.nim b/src/bot.nim
new file mode 100644 (file)
index 0000000..dc99043
--- /dev/null
@@ -0,0 +1,73 @@
+import dimscord, asyncdispatch, times, options
+import random
+import std/sequtils
+import std/strutils
+import std/random
+import std/envvars
+import dotenv
+import os
+
+load()
+
+randomize()
+
+let token = getEnv("TOKEN")
+let discord = newDiscordClient(token)
+const ballsChannel = "1370453399463530496";
+const getOutBot = "1349260113717891072"
+
+# Handle event for on_ready.
+proc onReady(s: Shard, r: Ready) {.event(discord).} =
+  echo "Ready as " & $r.user
+
+# Handle event for message_create.
+proc messageCreate(s: Shard, m: Message) {.event(discord).} =
+  let
+    channel = m.gchannel
+
+  if rand(100) < 02:
+    await m.react("distorted_face:1541167187694460999")
+
+  if rand(100) < 10:
+    let messages = ["gimme balls", "balls", "more balls"]
+    echo "sending to balls channel"
+    discard await discord.api.sendMessage(ballsChannel, messages[rand(messages.high)])
+
+  if m.author.username == "mooooooo0":
+    if rand(100) < 03:
+      await m.react("🫡")
+    if rand(100) < 02:
+      discard await m.reply("what that guy said", mention = true)
+
+  if m.referenced_message.isSome():
+    if m.referenced_message.get().author.username == "moo bot" and not (m.author.id == getOutBot):
+      discard await m.reply("it is I", mention = true)
+
+  if m.content.contains("moo") or m.content.contains("taran"):
+    discard await m.reply("ig bro", mention = true)
+
+  if m.author.id == getOutBot and rand(100) < 55:
+    let responses = ["stfu bot", "get a load of this guy ^^", "NERD ALERT ðŸš¨"]
+    discard await m.reply(responses[rand(responses.high)], mention = true)
+
+  if rand(100) < 05:
+    let emojis = ["🥵", "🥶", "🤯", "🤓", "🫦", "🪱", "🦧"]
+    await m.react(emojis[rand(emojis.high)])
+
+  if m.content.contains("simon says kys"):
+    discard await channel.send("bye bye")
+    quit(0)
+
+
+
+# Connect to Discord and run the bot.
+waitFor discord.startSession(gateway_intents={
+  giGuilds,
+  giGuildEmojisAndStickers,
+  giGuildMessages,
+  giGuildMessageReactions,
+  giDirectMessages,
+  giDirectMessageReactions,
+  giMessageContent
+ }) # Don't forget to specify the gateway_intent argument and double check your priviliged intent
+