public interface tweaks and such
This commit is contained in:
@@ -6,7 +6,7 @@ slug: getting-started
|
||||
|
||||
# Getting Started
|
||||
|
||||
These guides assume some familiarity with JavaScript, [React](https://reactjs.org), [Discord.js](https://discord.js.org) and the [Discord API](https://discord.dev). Keep these pages as reference if you need it.
|
||||
These guides assume some familiarity with [JavaScript](https://developer.mozilla.org/en-US/docs/Web/javascript), [React](https://reactjs.org), [Discord.js](https://discord.js.org) and the [Discord API](https://discord.dev). Keep these pages as reference if you need it.
|
||||
|
||||
## Setup from template
|
||||
|
||||
@@ -47,6 +47,13 @@ await client.login(process.env.BOT_TOKEN)
|
||||
To use JSX in your code, run it with [tsx](https://npm.im/tsx):
|
||||
|
||||
```bash
|
||||
npm install tsx
|
||||
tsx main.tsx
|
||||
npm install -D tsx
|
||||
npx tsx main.tsx
|
||||
```
|
||||
|
||||
For production, I recommend compiling it with [tsup](https://npm.im/tsup):
|
||||
|
||||
```bash
|
||||
npm install -D tsup
|
||||
npx tsup src/main.tsx --target node20
|
||||
```
|
||||
|
||||
@@ -36,7 +36,6 @@ function Uptime() {
|
||||
|
||||
client.on("ready", () => {
|
||||
const instance = reacord.createChannelMessage(channel)
|
||||
|
||||
instance.render(<Uptime />)
|
||||
})
|
||||
```
|
||||
@@ -48,26 +47,25 @@ const Hello = ({ subject }) => <>Hello, {subject}!</>
|
||||
|
||||
client.on("ready", () => {
|
||||
const instance = reacord.createChannelMessage(channel)
|
||||
|
||||
instance.render(<Hello subject="World" />)
|
||||
instance.render(<Hello subject="Moon" />)
|
||||
})
|
||||
```
|
||||
|
||||
## Replying to Messages
|
||||
|
||||
Instead of sending messages to a channel, you may want to reply to a specific message instead. To do this, create an instance using `.createMessageReply()` instead:
|
||||
You can specify various options for the message:
|
||||
|
||||
```jsx
|
||||
const Hello = ({ username }) => <>Hello, {username}!</>
|
||||
|
||||
client.on("messageCreate", (message) => {
|
||||
reacord
|
||||
.createMessageReply(message)
|
||||
.render(<Hello username={message.author.displayName} />)
|
||||
const instance = reacord.createChannelMessage(channel, {
|
||||
tts: true,
|
||||
reply: {
|
||||
messageReference: someMessage.id,
|
||||
},
|
||||
flags: [MessageFlags.SuppressNotifications],
|
||||
})
|
||||
```
|
||||
|
||||
See the [Discord.js docs](https://discord.js.org/#/docs/discord.js/main/typedef/MessageCreateOptions) for all of the available options.
|
||||
|
||||
## Cleaning Up Instances
|
||||
|
||||
If you no longer want to use the instance, you can clean it up in a few ways:
|
||||
@@ -91,7 +89,7 @@ const reacord = new ReacordDiscordJs(client, {
|
||||
This section also applies to other kinds of application commands, such as context menu commands.
|
||||
</aside>
|
||||
|
||||
To reply to a command interaction, use the `.createInteractionReply()` function. This function returns an instance that works the same way as the one from `.createChannelMessage()` and `.createMessageReply()`. Here's an example:
|
||||
To reply to a command interaction, use the `.createInteractionReply()` function. This function returns an instance that works the same way as the one from `.createChannelMessage()`. Here's an example:
|
||||
|
||||
```jsx
|
||||
import { Client } from "discord.js"
|
||||
@@ -163,11 +161,7 @@ handleCommands(client, [
|
||||
])
|
||||
```
|
||||
|
||||
## Interaction Options
|
||||
|
||||
Just like `.createChannelMessage()` and `.createMessageReply()`, interaction replies provide a way to specify certain `interaction.reply()` options.
|
||||
|
||||
### Ephemeral Command Replies
|
||||
## Ephemeral Command Replies
|
||||
|
||||
Ephemeral replies are replies that only appear for one user. To create them, use the `.createInteractionReply()` function and provide `ephemeral` option.
|
||||
|
||||
@@ -185,7 +179,7 @@ handleCommands(client, [
|
||||
])
|
||||
```
|
||||
|
||||
### Text-to-Speech Command Replies
|
||||
## Text-to-Speech Command Replies
|
||||
|
||||
Additionally interaction replies may have `tts` option to turn on text-to-speech ability for the reply. To create such reply, use `.createInteractionReply()` function and provide `tts` option.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user