2020-11-08 07:16:24 +00:00
|
|
|
# harmony
|
2020-10-21 16:30:42 +00:00
|
|
|
|
2020-11-06 10:42:00 +00:00
|
|
|
![banner](banner.png)
|
|
|
|
|
2020-11-02 16:09:12 +00:00
|
|
|
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
|
|
|
|
|
2020-11-06 08:27:56 +00:00
|
|
|
**An easy to use Discord API Library for Deno.**
|
|
|
|
* Lightweight and easy to use.
|
2020-11-07 09:14:28 +00:00
|
|
|
* Built-in Command Framework,
|
|
|
|
* Easily build Commands on the fly.
|
2020-11-08 08:51:14 +00:00
|
|
|
* Completely Customizable.
|
2020-11-07 09:14:28 +00:00
|
|
|
* Complete Object-Oriented approach.
|
2020-11-06 08:27:56 +00:00
|
|
|
* 100% Discord API Coverage.
|
|
|
|
* Customizable caching.
|
|
|
|
* Built in support for Redis.
|
|
|
|
* Write Custom Cache Adapters.
|
|
|
|
* Complete TypeScript support.
|
|
|
|
|
|
|
|
Note: Library is yet under development and not completely usable. You're still always welcome to use, but there may be breaking changes.
|
2020-11-02 16:09:12 +00:00
|
|
|
|
|
|
|
## Table of Contents
|
|
|
|
|
|
|
|
- [Usage](#usage)
|
|
|
|
- [Docs](#docs)
|
2020-11-03 23:00:03 +00:00
|
|
|
- [Maintainer](#maintainer)
|
2020-11-02 16:09:12 +00:00
|
|
|
- [Contributing](#contributing)
|
|
|
|
- [License](#license)
|
|
|
|
|
|
|
|
## Usage
|
2020-11-06 08:27:56 +00:00
|
|
|
Right now, the package is not published anywhere, as its not completely usable.
|
2020-11-08 07:16:24 +00:00
|
|
|
You can import it from this Raw GitHub URL: https://raw.githubusercontent.com/harmony-org/harmony/main/mod.ts
|
2020-11-06 08:27:56 +00:00
|
|
|
|
|
|
|
For a quick example, run this:
|
|
|
|
```bash
|
2020-11-08 07:16:24 +00:00
|
|
|
deno run --allow-net https://raw.githubusercontent.com/harmony-org/harmony/main/examples/ping.ts
|
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-11-02 16:09:12 +00:00
|
|
|
```ts
|
2020-11-08 07:53:42 +00:00
|
|
|
import { Client, Message, Intents } from 'https://raw.githubusercontent.com/harmony-org/harmony/main/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!
|
|
|
|
```ts
|
2020-11-08 07:16:24 +00:00
|
|
|
import { CommandClient, Command, CommandContext, Message, Intents } from 'https://raw.githubusercontent.com/harmony-org/harmony/main/mod.ts'
|
2020-11-07 09:14:28 +00:00
|
|
|
|
|
|
|
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.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-11-02 16:09:12 +00:00
|
|
|
## Docs
|
|
|
|
|
2020-11-06 08:27:56 +00:00
|
|
|
Not made yet.
|
2020-11-02 16:09:12 +00:00
|
|
|
|
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-11-03 09:21:29 +00:00
|
|
|
PRs 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
|
|
|
|
|
2020-11-03 09:21:29 +00:00
|
|
|
[MIT © 2020 Helloyunho](LICENSE)
|