Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harmonyland/harmony
An easy to use Discord API Library for Deno.
https://github.com/harmonyland/harmony
api deno discord discord-api framework hacktoberfest harmony javascript js ts typescript
Last synced: 5 days ago
JSON representation
An easy to use Discord API Library for Deno.
- Host: GitHub
- URL: https://github.com/harmonyland/harmony
- Owner: harmonyland
- License: mit
- Created: 2020-10-20T14:58:42.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-27T13:41:36.000Z (4 months ago)
- Last Synced: 2024-12-02T08:36:01.154Z (10 days ago)
- Topics: api, deno, discord, discord-api, framework, hacktoberfest, harmony, javascript, js, ts, typescript
- Language: TypeScript
- Homepage: https://harmony.mod.land
- Size: 4.72 MB
- Stars: 320
- Watchers: 8
- Forks: 48
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- discord-api-libs - harmony - An easy to use Discord API Library for Deno. (Libraries / TypeScript)
- awesome-discord - Harmony
- awesome-discord-bot-tools - Harmony - An easy to use Discord API Library for Deno. (Libraries / JavaScript)
- awesome-discord-bot-tools - Harmony - An easy to use Discord API Library for Deno. (Libraries / JavaScript)
README
![banner](./assets/banner.png)
An easy to use Discord API Library for Deno and Node.js
- 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 (Deno)
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.
## Usage (Node.js)
You can install and use the NPM package published under `@harmonyland/harmony`.
## Documentation
Documentation is available [main branch](https://doc.deno.land/https/raw.githubusercontent.com/harmonyland/harmony/main/mod.ts) or [latest stable version](https://doc.deno.land/https/deno.land/x/harmony/mod.ts). You can also check out the [guide](https://harmony.mod.land).
## Example
For a quick example, run this:
```bash
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,
```ts
import {
Client,
Message,
GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'const client = new Client({
intents: [
'GUILDS',
'DIRECT_MESSAGES',
'GUILD_MESSAGES'
],
// token: optionally specify, otherwise DISCORD_TOKEN from env is used
})// 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()
```Or with CommandClient!
```ts
import {
CommandClient,
Command,
CommandContext,
GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'const client = new CommandClient({
prefix: '!',
intents: [
'GUILDS',
'DIRECT_MESSAGES',
'GUILD_MESSAGES'
],
// token: optionally specify, otherwise DISCORD_TOKEN from env is used
})// 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()
```Or with Decorators!
```ts
import {
event,
CommandClient,
command,
CommandContext,
GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'class MyClient extends CommandClient {
constructor() {
super({
prefix: ['!', '!!'],
caseSensitive: false,
intents: [
'GUILDS',
'DIRECT_MESSAGES',
'GUILD_MESSAGES'
],
// token: optionally specify, otherwise DISCORD_TOKEN from env is used
})
}@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()
```## Discord
Need support? Join our Discord Server!
[![Harmony Discord Server](https://discord.com/api/guilds/783319033205751809/widget.png?style=banner1)](https://discord.gg/harmony)
## Maintainer
[@Helloyunho](https://github.com/Helloyunho)
## Contributing
See [the contributing file](CONTRIBUTING.md)!
Pull requests are welcome!
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
[MIT © 2020-2023 Harmony Land](LICENSE)
#### Made with ❤ by Harmony Land