2020-12-02 10:52:11 +00:00
![banner ](https://cdn.discordapp.com/attachments/783319033730564098/783399012547035176/HarmonyBanner.png )
2020-11-06 10:42:00 +00:00
2020-12-02 10:48:55 +00:00
< p align = center > < i > < b > An easy to use Discord API Library for Deno< / b > < / i > < / p >
< p align = center >
< img src = "https://img.shields.io/badge/standard--readme-OK-green.svg?style=for-the-badge" / >
< a href = https://discord.gg/WVN2JF2FRv >
< img src = "https://img.shields.io/discord/783319033205751809.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge" alt = "Support" >
< / a >
< / p >
< br >
- Lightweight and easy to use.
2020-12-22 06:58:45 +00:00
- Complete Object-Oriented approach.
- Slash Commands supported.
- Built-in Commands framework.
- Customizable Caching, with Redis support.
- Use `@decorators` to easily make things!
- Made with ❤️ TypeScript.
2020-11-06 08:27:56 +00:00
2020-11-02 16:09:12 +00:00
## Table of Contents
- [Usage ](#usage )
- [Docs ](#docs )
2020-12-02 04:30:14 +00:00
- [Discord ](#discord )
2020-11-03 23:00:03 +00:00
- [Maintainer ](#maintainer )
2020-11-02 16:09:12 +00:00
- [Contributing ](#contributing )
- [License ](#license )
## Usage
2020-12-02 10:48:55 +00:00
2020-12-03 09:38:55 +00:00
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/harmony-org/harmony/main/mod.ts too.
2020-11-06 08:27:56 +00:00
For a quick example, run this:
2020-12-02 10:48:55 +00:00
2020-11-06 08:27:56 +00:00
```bash
2020-12-03 11:07:35 +00:00
deno run --allow-net https://deno.land/x/harmony/examples/ping.ts
2020-11-06 08:27:56 +00:00
```
2020-12-02 10:48:55 +00:00
2020-11-06 08:27:56 +00:00
And input your bot's token and Intents.
2020-11-02 16:09:12 +00:00
2020-11-08 07:29:06 +00:00
Here is a small example of how to use harmony,
2020-12-02 10:48:55 +00:00
2020-11-02 16:09:12 +00:00
```ts
2020-12-05 07:20:08 +00:00
import { Client, Message, Intents } from 'https://deno.land/x/harmony/mod.ts'
2020-11-06 08:27:56 +00:00
const client = new Client()
2020-11-02 16:09:12 +00:00
2020-11-06 10:42:00 +00:00
// Listen for event when client is ready (Identified through gateway / Resumed)
2020-11-06 08:27:56 +00:00
client.on('ready', () => {
console.log(`Ready! User: ${client.user?.tag}`)
})
2020-11-02 16:09:12 +00:00
2020-11-06 10:42:00 +00:00
// Listen for event whenever a Message is sent
2020-11-06 08:27:56 +00:00
client.on('messageCreate', (msg: Message): void => {
2020-11-02 16:09:12 +00:00
if (msg.content === '!ping') {
2020-11-06 08:27:56 +00:00
msg.channel.send(`Pong! WS Ping: ${client.ping}`)
2020-11-02 16:09:12 +00:00
}
})
2020-11-06 10:42:00 +00:00
// Connect to gateway
2020-11-09 10:29:16 +00:00
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers)
2020-11-06 08:27:56 +00:00
client.connect('super secret token comes here', Intents.All)
2020-11-02 16:09:12 +00:00
```
2020-11-07 09:14:28 +00:00
Or with CommandClient!
2020-12-02 10:48:55 +00:00
2020-11-07 09:14:28 +00:00
```ts
2020-12-02 10:48:55 +00:00
import {
CommandClient,
Command,
CommandContext,
Message,
2020-12-02 12:29:52 +00:00
Intents
2020-12-03 11:07:35 +00:00
} from 'https://deno.land/x/harmony/mod.ts'
2020-11-07 09:14:28 +00:00
const client = new CommandClient({
2020-12-02 12:29:52 +00:00
prefix: '!'
2020-11-07 09:14:28 +00:00
})
// 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 {
2020-12-02 10:48:55 +00:00
name = 'ping'
2020-11-07 09:14:28 +00:00
execute(ctx: CommandContext) {
ctx.message.reply(`pong! Ping: ${ctx.client.ping}ms`)
}
}
client.commands.add(PingCommand)
// Connect to gateway
2020-11-09 10:29:16 +00:00
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers)
2020-11-07 09:14:28 +00:00
client.connect('super secret token comes here', Intents.All)
```
2020-12-17 08:59:36 +00:00
Or with Decorators!
2020-12-22 06:58:45 +00:00
2020-12-14 13:24:53 +00:00
```ts
import {
2020-12-17 08:59:36 +00:00
Client,
2020-12-14 13:24:53 +00:00
event,
Intents,
command,
2020-12-22 06:58:45 +00:00
CommandContext
2020-12-14 13:24:53 +00:00
} 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!')
}
}
// Connect to gateway
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers)
2020-12-17 08:59:36 +00:00
new MyClient().connect('super secret token comes here', Intents.All)
2020-12-14 13:24:53 +00:00
```
2020-11-02 16:09:12 +00:00
## Docs
2020-12-03 09:38:55 +00:00
Documentation is available for `main` (branch) and `stable` (release).
2020-12-05 07:20:08 +00:00
2020-12-03 12:35:36 +00:00
- [Main ](https://doc.deno.land/https/raw.githubusercontent.com/harmony-org/harmony/main/mod.ts )
2020-12-03 09:38:55 +00:00
- [Stable ](https://doc.deno.land/https/deno.land/x/harmony/mod.ts )
2020-12-22 06:58:45 +00:00
- [Guide ](https://harmony-org.github.io )
2020-11-02 16:09:12 +00:00
2020-12-02 10:48:55 +00:00
## Found a bug or want support? Join our discord server!
2020-12-02 04:30:14 +00:00
[![Widget for the Discord Server ](https://discord.com/api/guilds/783319033205751809/widget.png?style=banner1 )](https://discord.gg/WVN2JF2FRv)
2020-11-03 23:00:03 +00:00
## Maintainer
2020-11-02 16:09:12 +00:00
[@Helloyunho ](https://github.com/Helloyunho )
## Contributing
See [the contributing file ](CONTRIBUTING.md )!
2020-12-02 10:48:55 +00:00
Pull Requests are accepted.
2020-11-02 16:09:12 +00:00
Small note: If editing the README, please conform to the [standard-readme ](https://github.com/RichardLitt/standard-readme ) specification.
## License
2021-01-10 10:31:47 +00:00
[MIT © 2020-21 Harmony Org ](LICENSE )
2020-12-02 10:48:55 +00:00
#### Made with ❤ by Harmony-org