All Projects → skwair → harmony

skwair / harmony

Licence: MIT License
Harmony is a peaceful Go module for interacting with Discord's API

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to harmony

Cf Workers Status Page
Monitor your websites, showcase status including daily history, and get Slack/Telegram/Discord notification whenever your website status changes. Using Cloudflare Workers, CRON Triggers, and KV storage.
Stars: ✭ 247 (+149.49%)
Mutual labels:  discord
Discord-Token-Grabber
Steal Discord Token Directly From Memory and bypass any kind of token protection
Stars: ✭ 32 (-67.68%)
Mutual labels:  discord
easypoll-v3
EasyPoll Discord Bot | With EasyPoll, a Discord Poll Bot, you can easily create polls and your members can vote by clicking on a reaction very easily and quickly.
Stars: ✭ 35 (-64.65%)
Mutual labels:  discord
Sidekick
Dice and LFG bot for Discord.
Stars: ✭ 254 (+156.57%)
Mutual labels:  discord
pagkibot
Discord bot for instant Twitch live notifications using Twitch's PubSub API.
Stars: ✭ 25 (-74.75%)
Mutual labels:  discord
CreArts-Discord
CreArts is an easily customizable theme that customizes the appearance.
Stars: ✭ 139 (+40.4%)
Mutual labels:  discord
Bot
A super Awesome Discord bot
Stars: ✭ 247 (+149.49%)
Mutual labels:  discord
Fluent-Discord
Currently in-development Fluent Discord theme.
Stars: ✭ 22 (-77.78%)
Mutual labels:  discord
Green-bot
🎧 Green-bot is a powerfull discord music bot used by 10M users and more than 50,000 servers
Stars: ✭ 103 (+4.04%)
Mutual labels:  discord
warnable
Simple Discord bot to moderate Discord servers, specifically to warn members.
Stars: ✭ 34 (-65.66%)
Mutual labels:  discord
Aqua-Bot
디스코드 NSFW 챗봇 아쿠아 봇입니다.
Stars: ✭ 13 (-86.87%)
Mutual labels:  discord
Chill
CHILL - Discord Bot
Stars: ✭ 15 (-84.85%)
Mutual labels:  discord
Discord-Bot-Choo-Choo
Coding Train Example Discord Bot
Stars: ✭ 35 (-64.65%)
Mutual labels:  discord
Rpc
A simple RPC client for Discord
Stars: ✭ 248 (+150.51%)
Mutual labels:  discord
disco-oauth
A library for easing the use of https://discordapp.com 's OAuth2 API
Stars: ✭ 30 (-69.7%)
Mutual labels:  discord
Jetbrains Discord Integration
Discord rich presence integration for all JetBrains IDEs
Stars: ✭ 247 (+149.49%)
Mutual labels:  discord
vimsence
Discord Rich Presence plugin for Vim
Stars: ✭ 138 (+39.39%)
Mutual labels:  discord
discord-ui
A discord.py extension for sending, receiving and handling ui interactions in discord
Stars: ✭ 28 (-71.72%)
Mutual labels:  discord
cytrus-re
A multipurpose Discord bot!
Stars: ✭ 16 (-83.84%)
Mutual labels:  discord
Discord-Rich-Presence
Rich presence for Discord to be a cool kid in your class !!
Stars: ✭ 26 (-73.74%)
Mutual labels:  discord

GoDoc License MIT Discord Build Status

Harmony

Harmony is a peaceful Go module for interacting with Discord's API.

Although this package is usable, it still is under active development so please don't use it for anything other than experiments, yet.

Contents

Installation

Make sure you have a working Go installation, if not see this page first.

Then, install this package with the go get command:

go get github.com/skwair/harmony

Note that go get will always pull the latest version from the master branch before Go 1.11. With newer versions and Go modules enabled, the latest minor or patch release will be downloaded. go get github.com/skwair/[email protected] can be used to download a specific version. See Go modules for more information.

Usage

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/skwair/harmony"
)

func main() {
    client, err := harmony.NewClient("your.bot.token")
    if err != nil {
        log.Fatal(err)
    }

    // Get information about the current user (the bot itself).
    u, err := client.User("@me").Get(context.Background())
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(u)
}

For information about how to create bots and more examples on how to use this package, check out the examples directory and the tests.

Testing

For now, only some end to end tests are provided with this module. To run them, you will need a valid bot token and a valid Discord server ID. The bot attached to the token must be in the server with administrator permissions.

  1. Create a Discord test server

From a Discord client and with you main account, simply create a new server. Then, right click on the new server and get its ID.

Note that for the UI to have the Copy ID option when right clicking on the server, you will need to enable developer mode. You can find this option in User settings > Appearance > Advanced > Developer Mode.

  1. Create a bot and add it to the test Discord server

Create a bot (or use an existing one) and add it to the freshly created server.

See the example directory for information on how to create a bot and add it to a server.

  1. Set required environment variables and run the tests

Set HARMONY_TEST_BOT_TOKEN to the token of your bot and HARMONY_TEST_GUILD_ID to the ID of the server you created and simply run:

⚠️ For the tests to be reproducible, they will start by deleting ALL channels in the provided server. Please make sure to provide a server created ONLY for those tests. ⚠️

go test -v -race ./...

Step 1 and 2 must be done only once for initial setup. Once you have your bot token and the ID of your test server, you can run the tests as many times as you want.

How does it compare to DiscordGo?

Harmony exposes its API differently. It uses a resource-based approach which organizes methods by topic, greatly reducing the number of methods on the main Client type. The goal by doing this is to have a more friendly API which is easier to navigate.

Another key difference is in the "event handler" mechanism. Instead of having a single method that takes an interface{} as a parameter and guesses which event you registered a handler for based on its concrete type, this library provides a dedicated method for each event type, making it clear what signature your handler must have and ensuring it at compile time, not at runtime.

Each action that results in an entry in the audit log has a ...WithReason form, allowing to set a reason for the change (see the X-Audit-Log-Reason header documentation for more information).

Finally, this library has a full support of the context package, allowing the use of timeouts, deadlines and cancellation when interacting with Discord's API.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Original logo by Renee French, dressed with the cool t-shirt by @HlneChd.

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].