No description
Find a file
2025-10-19 12:26:43 +01:00
.github/workflows brute-force 1 with nim iffy github actions bare with me 2025-09-23 00:15:00 +01:00
assets add image logo 2020-07-16 17:02:58 +01:00
dimscord i.application_id -> i.id (#139) 2025-10-19 12:26:43 +01:00
docs split_first_shard parameter, update examples and docs 2025-09-28 21:54:22 +01:00
examples split_first_shard parameter, update examples and docs 2025-09-28 21:54:22 +01:00
tests couple of last fixes to helpers (#137) 2025-09-19 20:00:02 +01:00
.gitignore Added all thread and stage endpoints (I think). Rewritten GuildChannel, fix sendMessage and executeWebhook error. Some updates to last commit and tweaked on ire4ever1190's PR. 2021-08-15 18:19:14 +01:00
CONTRIBUTING.md Added all thread and stage endpoints (I think). Rewritten GuildChannel, fix sendMessage and executeWebhook error. Some updates to last commit and tweaked on ire4ever1190's PR. 2021-08-15 18:19:14 +01:00
dimscord.nim Enforce Nim version requirement, refined json parsings with some notable patches 2025-09-06 21:25:33 +01:00
dimscord.nimble Dimscord v1.8.0 2025-09-28 21:58:07 +01:00
LICENSE split_first_shard parameter, update examples and docs 2025-09-28 21:54:22 +01:00
README.md Update README.md example 2025-09-29 07:02:03 +01:00

Dimscord

A Discord Bot & REST Library for Nim. Discord API Channel and Dimscord Server for help

Why Dimscord?

  • It is minimalistic and efficient.
  • Nim is a good programming language and I believe that Nim should stand a chance on having an up-to-date, substantial discord library.
  • It has a REST-mode only feature, which isn't cache-reliant.
  • The other Nim Discord library (discordnim) has bunch of issues, and it's unmaintained.

FAQ:

  • What is Nim?
  • Why use Nim for Discord bots?
    • Since it's easier to learn, it's faster than any other interpreted languages, which is beneficial for the performance of larger discord bots. You can read the Nim FAQ here
  • Is there a command handler for Dimscord?
    • Yes, but not in this library.

Getting Started:

  1. Install Nim using choosenim or Nim's website

  2. Install Dimscord via Nimble using nimble install dimscord or GitHub git clone https://github.com/krisppurg/dimscord

    • You will need at least Nim 2.0.6 to install dimscord
  3. Read the Wiki or Examples for referencing. Maybe even rewrite your bot if you want to switch.

  4. Start coding! Stay up-to-date with the latest Dimscord release and stuff.

Quick Example:

import dimscord, asyncdispatch, times, options

let discord = newDiscordClient("<your bot token goes here>")

# 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).} =
    if m.author.bot: return
    if m.content == "!ping": # If message content is "!ping".
        let
            before = epochTime() * 1000
            msg = await discord.api.sendMessage(m.channel_id, "ping?")
            after = epochTime() * 1000
        # Now edit the message.
        # Use 'discard' because editMessage returns a new message.
        discard await discord.api.editMessage(
            m.channel_id,
            msg.id, 
            "Pong! took " & $int(after - before) & "ms | " & $s.latency() & "ms."
        )
    elif m.content == "!embed": # Otherwise if message content is "!embed".
        # Sends a message with embed.
        discard await discord.api.sendMessage(
            m.channel_id,
            embeds = @[Embed(
                title: some "Hello there!", 
                description: some "This is description",
                color: some 0x7789ec
            )]
        )

# Connect to Discord and run the bot.
waitFor discord.startSession(gateway_intents={giMessageContent, giGuildMessages}) # Don't forget to specify the gateway_intent argument and double check your priviliged intent

Please note that you need to define -d:ssl if you are importing httpclient before importing dimscord. You can use -d:dimscordDebug, if you want to debug.

If you want to use voice then you can use -d:dimscordVoice, this requires libsodium, libopus, ffmpeg and optionally yt-dlp (by default)

Contributing

  • If you are interested in contributing to Dimscord, I'd recommend reading the CONTRIBUTING.md file.