mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
docs: use ESM code in examples (#9427)
* docs(Partials): use import statement * docs: update readme to ESM --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -57,7 +57,7 @@ pnpm add discord.js
|
|||||||
Register a slash command against the Discord API:
|
Register a slash command against the Discord API:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { REST, Routes } = require('discord.js');
|
import { REST, Routes } from 'discord.js';
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
@@ -68,23 +68,21 @@ const commands = [
|
|||||||
|
|
||||||
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
||||||
|
|
||||||
(async () => {
|
try {
|
||||||
try {
|
console.log('Started refreshing application (/) commands.');
|
||||||
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.');
|
console.log('Successfully reloaded application (/) commands.');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards we can create a quite simple example bot:
|
Afterwards we can create a quite simple example bot:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { Client, GatewayIntentBits } = require('discord.js');
|
import { Client, GatewayIntentBits } from 'discord.js';
|
||||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { createEnum } = require('./Enums');
|
|||||||
/**
|
/**
|
||||||
* The enumeration for partials.
|
* The enumeration for partials.
|
||||||
* ```js
|
* ```js
|
||||||
* const { Client, Partials } = require('discord.js');
|
* import { Client, Partials } from 'discord.js';
|
||||||
*
|
*
|
||||||
* const client = new Client({
|
* const client = new Client({
|
||||||
* intents: [
|
* intents: [
|
||||||
|
|||||||
Reference in New Issue
Block a user