Skip to content

Commit

Permalink
docs: use ESM code in examples (#9427)
Browse files Browse the repository at this point in the history
* docs(Partials): use import statement

* docs: update readme to ESM

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
MrMythicalYT and kodiakhq[bot] committed Apr 20, 2023
1 parent d6bca9b commit ce287f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions packages/discord.js/README.md
Expand Up @@ -57,7 +57,7 @@ pnpm add discord.js
Register a slash command against the Discord API:

```js
const { REST, Routes } = require('discord.js');
import { REST, Routes } from 'discord.js';

const commands = [
{
Expand All @@ -68,23 +68,21 @@ const commands = [

const rest = new REST({ version: '10' }).setToken(TOKEN);

(async () => {
try {
console.log('Started refreshing application (/) commands.');
try {
console.log('Started refreshing application (/) commands.');

await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });
await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
```

Afterwards we can create a quite simple example bot:

```js
const { Client, GatewayIntentBits } = require('discord.js');
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on('ready', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/util/Partials.js
Expand Up @@ -5,7 +5,7 @@ const { createEnum } = require('./Enums');
/**
* The enumeration for partials.
* ```js
* const { Client, Partials } = require('discord.js');
* import { Client, Partials } from 'discord.js';
*
* const client = new Client({
* intents: [
Expand Down

0 comments on commit ce287f2

Please sign in to comment.