Git Product home page Git Product logo

dimscord's Introduction

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 1.2.0 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()

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.

dimscord's People

Contributors

krisppurg avatar ire4ever1190 avatar t8m8 avatar shadowninja55 avatar dannyhpy avatar yardanico avatar edelsora avatar filvyb avatar hendrikgit avatar infinitybeond1 avatar eieneika avatar sainttttt avatar bit0r1n avatar snus-kin avatar nayr7 avatar xxami avatar

Stargazers

akumarujon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.