No description
.github | ||
examples | ||
src | ||
test | ||
.eslintrc.js | ||
.gitignore | ||
.prettierrc | ||
banner.png | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
deps.ts | ||
LICENSE | ||
mod.ts | ||
package.json | ||
README.md | ||
tsconfig.json |
An easy to use Discord API Library for Deno
- Lightweight and easy to use.
- 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.
Table of Contents
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.
For a quick example, run this:
deno run --allow-net https://deno.land/x/harmony/examples/ping.ts
And input your bot's token and Intents.
Here is a small example of how to use harmony,
import { Client, Message, Intents } 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.ping}`)
}
})
// Connect to gateway
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers)
client.connect('super secret token comes here', Intents.All)
Or with CommandClient!
import {
CommandClient,
Command,
CommandContext,
Message,
Intents
} 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.ping}ms`)
}
}
client.commands.add(PingCommand)
// Connect to gateway
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers)
client.connect('super secret token comes here', Intents.All)
Or with Decorators!
import {
Client,
event,
Intents,
command,
CommandContext
} 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)
new MyClient().connect('super secret token comes here', Intents.All)
Docs
Documentation is available for main
(branch) and stable
(release).
Found a bug or want support? Join our discord server!
Maintainer
Contributing
Pull Requests are accepted.
Small note: If editing the README, please conform to the standard-readme specification.