update readme examples

This commit is contained in:
DjDeveloperr 2021-02-02 10:51:12 +05:30
parent ee51609c8c
commit 57863a6ed5

View file

@ -41,7 +41,11 @@ And input your bot's token and Intents.
Here is a small example of how to use harmony, Here is a small example of how to use harmony,
```ts ```ts
import { Client, Message, Intents } from 'https://deno.land/x/harmony/mod.ts' import {
Client,
Message,
GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts'
const client = new Client() const client = new Client()
@ -58,8 +62,11 @@ client.on('messageCreate', (msg: Message): void => {
}) })
// Connect to gateway // 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', [
client.connect('super secret token comes here', Intents.All) GatewayIntents.DIRECT_MESSAGES,
GatewayIntents.GUILDS,
GatewayIntents.GUILD_MESSAGES
])
``` ```
Or with CommandClient! Or with CommandClient!
@ -69,8 +76,7 @@ import {
CommandClient, CommandClient,
Command, Command,
CommandContext, CommandContext,
Message, GatewayIntents
Intents
} from 'https://deno.land/x/harmony/mod.ts' } from 'https://deno.land/x/harmony/mod.ts'
const client = new CommandClient({ const client = new CommandClient({
@ -94,19 +100,22 @@ class PingCommand extends Command {
client.commands.add(PingCommand) client.commands.add(PingCommand)
// Connect to gateway // 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', [
client.connect('super secret token comes here', Intents.All) GatewayIntents.DIRECT_MESSAGES,
GatewayIntents.GUILDS,
GatewayIntents.GUILD_MESSAGES
])
``` ```
Or with Decorators! Or with Decorators!
```ts ```ts
import { import {
Client,
event, event,
Intents, CommandClient,
command, command,
CommandContext CommandContext,
GatewayIntents
} from 'https://deno.land/x/harmony/mod.ts' } from 'https://deno.land/x/harmony/mod.ts'
class MyClient extends CommandClient { class MyClient extends CommandClient {
@ -128,9 +137,11 @@ class MyClient extends CommandClient {
} }
} }
// Connect to gateway new MyClient().connect('super secret token comes here', [
// Replace with your bot's token and intents (Intents.All, Intents.None, Intents.Presence, Intents.GuildMembers) GatewayIntents.DIRECT_MESSAGES,
new MyClient().connect('super secret token comes here', Intents.All) GatewayIntents.GUILDS,
GatewayIntents.GUILD_MESSAGES
])
``` ```
## Docs ## Docs