harmony/examples/ping.ts

44 lines
919 B
TypeScript
Raw Normal View History

import { Client, Message, Intents } 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!')
}
})
2020-11-08 07:58:24 +00:00
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()
}
2020-11-08 07:58:24 +00:00
const intents = prompt(
'Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None):'
)
if (intents === null || !['0', '1', '2', '3'].includes(intents)) {
console.log('No intents provided')
Deno.exit()
}
2020-11-08 07:58:24 +00:00
let ints
if (intents === '0') {
ints = Intents.All
} else if (intents === '1') {
ints = Intents.Presence
} else if (intents === '2') {
ints = Intents.GuildMembers
} else {
2020-11-08 07:58:24 +00:00
ints = Intents.None
}
2020-11-08 07:58:24 +00:00
client.connect(token, ints)