harmony/examples/ping.ts

29 lines
593 B
TypeScript
Raw Normal View History

import { Client, Message, GatewayIntents } from '../mod.ts'
2020-11-08 07:58:24 +00:00
const client = new Client()
2020-11-08 07:58:24 +00:00
client.on('ready', () => {
console.log(`Logged in as ${client.user?.tag}!`)
})
2020-11-08 07:58:24 +00:00
client.on('messageCreate', (msg: Message) => {
if (msg.content === '!ping') {
console.log('Command Used: Ping')
msg.reply('pong!')
}
})
console.log('Harmony - Ping Example')
2020-11-08 07:58:24 +00:00
const token = prompt('Input Bot Token:')
2020-11-07 02:53:42 +00:00
if (token === null) {
2020-11-08 07:58:24 +00:00
console.log('No token provided')
Deno.exit()
}
client.connect(token, [
GatewayIntents.GUILD_MESSAGES,
GatewayIntents.GUILDS,
GatewayIntents.DIRECT_MESSAGES
])