fix: both readmes were wrong

This commit is contained in:
Yuzu 2022-09-03 20:37:15 -05:00
parent 8bbdbeed64
commit e654c75455
2 changed files with 15 additions and 13 deletions

View File

@ -41,15 +41,16 @@ const commands = [
} }
]; ];
session.events.on('ready', async ({ user }) => { session.events.on('ready', ({ user }) => {
console.log('Logged in as:', user.username); console.log('Logged in as:', user.tag);
await session.upsertApplicationCommands(commands, 'GUILD_ID'); session.upsertApplicationCommands(commands, 'GUILD_ID');
}); });
session.events.on('interactionCreate', (interaction) => { session.events.on('interactionCreate', (interaction) => {
if (interaction.isCommand()) { if (interaction.isCommand()) {
// your commands go here
if (interaction.commandName === 'ping') { if (interaction.commandName === 'ping') {
interaction.respond({ with: { content: 'pong!' } }); interaction.respondWith({ content: 'pong!' });
} }
} }
}); });

View File

@ -16,27 +16,28 @@ yarn add @biscuitland/core
### Example bot ### Example bot
`project/index.js`: `project/index.js`:
```js ```js
import { ChatInputApplicationCommandBuilder, Session } from '@biscuitland/core'; import { Session } from '@biscuitland/core';
import { GatewayIntents } from '@biscuitland/api-types'; import { GatewayIntents } from '@biscuitland/api-types';
const session = new Session({ token: 'your token', intents: GatewayIntents.Guilds }); const session = new Session({ token: 'your token', intents: GatewayIntents.Guilds });
const commands = [ const commands = [
new ChatInputApplicationCommandBuilder() {
.setName('ping') name: 'ping',
.setDescription('Replies with pong!') description: 'Replies with pong!'
.toJSON() }
]; ];
session.events.on('ready', async ({ user }) => { session.events.on('ready', ({ user }) => {
console.log('Logged in as:', user.username); console.log('Logged in as:', user.tag);
await session.upsertApplicationCommands(commands, 'GUILD_ID'); session.upsertApplicationCommands(commands, 'GUILD_ID');
}); });
session.events.on('interactionCreate', (interaction) => { session.events.on('interactionCreate', (interaction) => {
if (interaction.isCommand()) { if (interaction.isCommand()) {
// your commands go here
if (interaction.commandName === 'ping') { if (interaction.commandName === 'ping') {
interaction.respond({ with: { content: 'pong!' } }); interaction.respondWith({ content: 'pong!' });
} }
} }
}); });