Giter Club home page Giter Club logo

harmony's Introduction

banner

An easy to use Discord API Library for Deno

Support


  • Lightweight and easy to use
  • Complete Object-Oriented approach
  • Slash Commands supported
  • Built-in Commands framework
  • Customizable Caching, with Redis support
  • @decorators supported
  • Made with ❤️ in TypeScript

Usage

You can import the package from https://deno.land/x/harmony/mod.ts (with latest version) or can add a version too, and raw GitHub URL (latest unpublished version) https://raw.githubusercontent.com/harmonyland/harmony/main/mod.ts too.

We also have a (fancy) custom registry for importing Harmony! It's at code.harmony.rocks, example import URL: https://code.harmony.rocks/v2.5.0.

Docs

Documentation is available main branch or latest stable version. You can also check out the guide.

Example

For a quick example, run this:

deno run --allow-net https://deno.land/x/harmony/examples/ping.ts

And input your bot's token.

Here is a small example of how to use harmony,

import {
  Client,
  Message,
  GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'

const client = new Client()

// Listen for event when client is ready (Identified through gateway / Resumed)
client.on('ready', () => {
  console.log(`Ready! User: ${client.user?.tag}`)
})

// Listen for event whenever a Message is sent
client.on('messageCreate', (msg: Message): void => {
  if (msg.content === '!ping') {
    msg.channel.send(`Pong! WS Ping: ${client.gateway.ping}`)
  }
})

// Connect to gateway
client.connect('super secret token comes here', [
  GatewayIntents.DIRECT_MESSAGES,
  GatewayIntents.GUILDS,
  GatewayIntents.GUILD_MESSAGES
])

Or with CommandClient!

import {
  CommandClient,
  Command,
  CommandContext,
  GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'

const client = new CommandClient({
  prefix: '!'
})

// Listen for event when client is ready (Identified through gateway / Resumed)
client.on('ready', () => {
  console.log(`Ready! User: ${client.user?.tag}`)
})

// Create a new Command
class PingCommand extends Command {
  name = 'ping'

  execute(ctx: CommandContext) {
    ctx.message.reply(`pong! Ping: ${ctx.client.gateway.ping}ms`)
  }
}

client.commands.add(PingCommand)

// Connect to gateway
client.connect('super secret token comes here', [
  GatewayIntents.DIRECT_MESSAGES,
  GatewayIntents.GUILDS,
  GatewayIntents.GUILD_MESSAGES
])

Or with Decorators!

import {
  event,
  CommandClient,
  command,
  CommandContext,
  GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'

class MyClient extends CommandClient {
  constructor() {
    super({
      prefix: ['!', '!!'],
      caseSensitive: false
    })
  }

  @event()
  ready(): void {
    console.log(`Logged in as ${this.user?.tag}!`)
  }

  @command({ aliases: 'pong' })
  Ping(ctx: CommandContext): void {
    ctx.message.reply('Pong!')
  }
}

new MyClient().connect('super secret token comes here', [
  GatewayIntents.DIRECT_MESSAGES,
  GatewayIntents.GUILDS,
  GatewayIntents.GUILD_MESSAGES
])

Discord

Found a bug or want support? Join our Discord Server!

Harmony Discord Server

Maintainer

@Helloyunho

Contributing

See the contributing file!

Pull requests are welcome!

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2020-2022 Harmonyland

Made with ❤ by Harmony Land

harmony's People

Contributors

6days9weeks avatar akiacode avatar almeidx avatar ayntee avatar cormanz avatar cubedhuang avatar develeon64 avatar djdeveloperr avatar eliasstar avatar financenoob avatar fishuke avatar grian32 avatar helloyunho avatar howtodosetmyusername avatar invalidcards avatar kiki7000 avatar loliticos avatar mierenmanz avatar minibox24 avatar minseo0388 avatar nebulatgs avatar netux avatar noamboy2006 avatar oliver-makes-code avatar preta-crowz avatar tejas1707 avatar tendto avatar tildezero avatar underc avatar ziomaleq 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.