All Projects → andersfylling → Disgord

andersfylling / Disgord

Licence: bsd-3-clause
Go module for interacting with the documented Discord's bot interface; Gateway, REST requests and voice

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Disgord

Discord4j
Discord4J is a fast, powerful, unopinionated, reactive library to enable quick and easy development of Discord bots for Java, Kotlin, and other JVM languages using the official Discord Bot API.
Stars: ✭ 973 (+251.26%)
Mutual labels:  api, discord-api, bot, discord
Dsharpplus
A .NET Standard library for making bots using the Discord API.
Stars: ✭ 635 (+129.24%)
Mutual labels:  api, discord-api, bot, discord
Aegis.cpp
Discord C++ library for interfacing with the API. Join our server:
Stars: ✭ 198 (-28.52%)
Mutual labels:  api, discord-api, bot, discord
Basicbot
A basic example of a Discord Bot written in Python. (discord.py)
Stars: ✭ 73 (-73.65%)
Mutual labels:  api, discord-api, bot, discord
Javacord
An easy to use multithreaded library for creating Discord bots in Java.
Stars: ✭ 368 (+32.85%)
Mutual labels:  api, discord-api, bot, discord
Discord Haskell
Haskell library for writing Discord bots
Stars: ✭ 129 (-53.43%)
Mutual labels:  discord-api, bot, discord
Music Bot
Simple music bot with a full-blown queue system that is easy to understand
Stars: ✭ 102 (-63.18%)
Mutual labels:  discord-api, bot, discord
Discord.net
An unofficial .Net wrapper for the Discord API (http://discordapp.com)
Stars: ✭ 2,253 (+713.36%)
Mutual labels:  discord-api, bot, discord
Discord.js Menu
💬 Easily create Discord.js v12 embed menus with reactions and unlimited customizable pages.
Stars: ✭ 89 (-67.87%)
Mutual labels:  discord-api, bot, discord
Lenoxbot
🖥️ LenoxBot is a Discord bot that offers many cool new features to your Discord server!
Stars: ✭ 163 (-41.16%)
Mutual labels:  discord-api, bot, discord
Discord Bot
🤖 Our BIG help in things about moderation and many more useful stuff on our Discord server.
Stars: ✭ 30 (-89.17%)
Mutual labels:  api, bot, discord
Discord.js
discord.js is a powerful Node.js module that allows you to easily interact with the Discord API.
Stars: ✭ 16,432 (+5832.13%)
Mutual labels:  discord-api, bot, discord
Discord Panel
📊 User friendly dashboard/tool for discord bot developpers to manage servers
Stars: ✭ 116 (-58.12%)
Mutual labels:  discord-api, bot, discord
Discordeno
Discord API library for Deno
Stars: ✭ 254 (-8.3%)
Mutual labels:  api, discord-api, discord
Node Sdk
An official module for interacting with the top.gg API
Stars: ✭ 90 (-67.51%)
Mutual labels:  api, bot, discord
Nostrum
Elixir Discord Library
Stars: ✭ 274 (-1.08%)
Mutual labels:  discord-api, bot, discord
Nino
🔨 Advanced and cute moderation discord bot as an entry of Discord's Hack Week!
Stars: ✭ 78 (-71.84%)
Mutual labels:  discord-api, bot, discord
Client
A Typescript NodeJS library to interact with Discord's API, both Rest and Gateway.
Stars: ✭ 84 (-69.68%)
Mutual labels:  discord-api, bot, discord
Dimscord
A Discord Bot & REST Library for Nim.
Stars: ✭ 67 (-75.81%)
Mutual labels:  api, discord-api, discord
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+837.91%)
Mutual labels:  api, bot, discord

About

Go module with context support that handles some of the difficulties from interacting with Discord's bot interface for you; websocket sharding, auto-scaling of websocket connections, advanced caching (cache replacement strategies to restrict memory usage), helper functions, middlewares and lifetime controllers for event handlers, etc.

This package is intented to be used with the gateway to keep the cache up to date. You should treat data as read only, since they simply represent the discord state. To change the discord state you can use the REST methods and the gateway commands, which will eventually update your local state as well.

If you want a more lightweight experience you can disable/reject events that you do not need or want to keep track of. Be careful as this might break certain things.

Warning

Remember to read the docs/code for whatever version of disgord you are using. This README file tries reflects the latest state in the develop branch.

By default DM capabilities are disabled. If you want to activate these, or some, specify their related intent.

client := disgord.New(disgord.Config{
    DMIntents: disgord.IntentDirectMessages | disgord.IntentDirectMessageReactions | disgord.IntentDirectMessageTyping,
})

Data types & tips

  • Use disgord.Snowflake, not snowflake.Snowflake.
  • Use disgord.Time, not time.Time when dealing with Discord timestamps.

Starter guide

This project uses Go Modules for dealing with dependencies, remember to activate module support in your IDE

Examples can be found in docs/examples and some open source projects Disgord projects in the wiki

I highly suggest reading the Discord API documentation and the Disgord go doc.

Simply use this github template to create your first new bot!

API / Interface

In short Disgord uses the builder pattern by respecting resources

The Client or Session holds are the relevant methods for interacting with Discord. The API is split by resource, such that Guild related information is found in Client.Guild(guild_id), while user related info is found in Client.User(user_id), gateway interaction is found in Client.Gateway(), the same for Channel, CurrentUser, Emoji, AuditLog, etc.

Cancellation is supported by calling .WithContext(context.Context before the final REST call (.Get(), .Update(), etc.).

Events

every event goes through the cache layer!

For Events, Disgord uses the reactor pattern. This supports both channels and functions. You chose your preference.

REST

If the request is a standard GET request, the cache is always checked first to reduce delay, network traffic and load on the Discord servers. And on responses, regardless of the http method, the data is copied into the cache.

// bypasses local cache
client.CurrentUser().Get(disgord.IgnoreCache)
client.Guild(guildID).GetMembers(disgord.IgnoreCache)

// always checks the local cache first
client.CurrentUser().Get()
client.Guild(guildID).GetMembers()

// with cancellation
deadline, _ := context.WithDeadline(context.Background(), time.Now().Add(2*time.Second))
client.CurrentUser().WithContext(deadline).Get()

Voice

Whenever you want the bot to join a voice channel, a websocket and UDP connection is established. So if your bot is currently in 5 voice channels, then you have 5 websocket connections and 5 udp connections open to handle the voice traffic.

Cache

The cache tries to represent the Discord state as accurate as it can. Because of this, the cache is immutable by default. Meaning the does not allow you to reference any cached objects directly, and every incoming and outgoing data of the cache is deep copied.

Contributing

Please see the CONTRIBUTING.md file (Note that it can be useful to read this regardless if you have the time)

You can contribute with pull requests, issues, wiki updates and helping out in the discord servers mentioned above.

To notify about bugs or suggesting enhancements, simply create a issue. The more the better. But be detailed enough that it can be reproduced and please provide logs.

To contribute with code, always create an issue before you open a pull request. This allows automating change logs and releases.

Sponsors

JetBrains

A Special thanks to the following companies for sponsoring this project!

Software used

Q&A

NOTE: To see more examples go to the docs/examples folder. See the GoDoc for a in-depth introduction on the various topics.

1. How do I find my bot token and/or add my bot to a server?

Tutorial here: https://github.com/andersfylling/disgord/wiki/Get-bot-token-and-add-it-to-a-server
2. Is there an alternative Go package?

Yes, it's called DiscordGo (https://github.com/bwmarrin/discordgo). Its purpose is to provide a 
minimalistic API wrapper for Discord, it does not handle multiple websocket sharding, scaling, etc. 
behind the scenes such as Disgord does. Currently I do not have a comparison chart of Disgord and 
DiscordGo. But I do want to create one in the future, for now the biggest difference is that 
Disgord does not support self bots.
3. Why make another Discord lib in Go?

I'm trying to take over the world and then become a intergalactic war lord. Have to start somewhere.
4. Will Disgord support self bots?

No. Self bots are againts ToS and could result in account termination (see
https://support.discord.com/hc/en-us/articles/115002192352-Automated-user-accounts-self-bots-). 
In addition, self bots aren't a part of the official Discord API, meaning support could change at
any time and Disgord could break unexpectedly if this feature were to be added.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].