Skip to content

Commit

Permalink
feature: add several new guides
Browse files Browse the repository at this point in the history
  • Loading branch information
4x8Matrix committed Jun 24, 2024
1 parent d9c50c8 commit d2c5ad6
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 1 deletion.
94 changes: 94 additions & 0 deletions src/content/docs/guides/attachments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: Message Attachments
description: Responding to discord commands/messages with Attachments
sidebar:
order: 4
---

import { Steps } from '@astrojs/starlight/components';
import { Aside } from '@astrojs/starlight/components';

[Attachments](https://discord.com/developers/docs/resources/channel#attachment-object) are a way to upload files to the Discord CDN, discord
luau supports sending these attachments through the `AttachmentBuilder` object.

<Steps>

1. Create a discord-luau bot implementation:

```lua
local DiscordLuau = require("DiscordLuau")

local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)

DiscordClient.eventManager.onMessage:connect(function(message)
if message.Content == "!embed" then
...
end
end)

DiscordClient.eventManager.onReady:connect(function()
print(`🎉🎉 {DiscordClient.discordUser.username} is online! 🎉🎉`)
end)

DiscordClient:connectAsync()
```

2. Create a Discord attachment that we can respond with:

```lua
local responseAttachment = DiscordLuau.AttachmentBuilder.new()
:setName("example.txt")
:setDescription("Example Text Document")
:setData("Hello, World - 'Tis be the data of this example document!")

```

3. Reply to the message with the newly created embed:

```lua
local responseMessage = DiscordLuau.MessageBuilder.new()
local responseAttachment = DiscordLuau.AttachmentBuilder.new()
:setName("example.txt")
:setDescription("Example Text Document")
:setData("Hello, World - 'Tis be the data of this example document!")

message:replyAsync(responseMessage:addFile(responseAttachment))
```
</Steps>

<details>
<summary>See The Entire Code</summary>

```lua
local DiscordLuau = require("DiscordLuau")

local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)

DiscordClient.eventManager.onMessage:connect(function(message)
if message.Content == "!embed" then
local responseMessage = DiscordLuau.MessageBuilder.new()
local responseAttachment = DiscordLuau.AttachmentBuilder.new()
:setName("example.txt")
:setDescription("Example Text Document")
:setData("Hello, World - 'Tis be the data of this example document!")

message:replyAsync(responseMessage:addFile(responseAttachment))
end
end)

DiscordClient.eventManager.onReady:connect(function()
print(`🎉🎉 {DiscordClient.discordUser.username} is online! 🎉🎉`)
end)

DiscordClient:connectAsync()
```
</details>

That's all! For more details, refer to the relevant docs;

- [DiscordAttachment](/classes/objects/discordattachment/)
- [EventManager](/classes/objects/eventmanager/)
- [DiscordMessage](/classes/objects/discordmessage/)
- [MessageBuilder](/classes/builders/messagebuilder/)
2 changes: 2 additions & 0 deletions src/content/docs/guides/basic.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Basic Application
description: A basic application that demo's getting started with Discord Luau
sidebar:
order: 1
---

import { Steps } from '@astrojs/starlight/components';
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/guides/commands.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Slash Commands
description: Registering and handling slash commands in DiscordLuau.
sidebar:
order: 2
---

import { Steps } from '@astrojs/starlight/components';
Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/guides/embeds.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Responding with Embeds
description: Responding to discord commands/messages with Embeds.
sidebar:
order: 3
---

import { Steps } from '@astrojs/starlight/components';
Expand All @@ -12,7 +14,7 @@ within a message.

<Steps>

1. Create a listener that will respond to a message:
1. Create a discord-luau bot implementation:

```lua
local DiscordLuau = require("DiscordLuau")
Expand Down
8 changes: 8 additions & 0 deletions src/content/docs/guides/minesweeper.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Implementing a Discord-Luau Minesweeper
description: Implementing an example Minesweeper game with Discord-Luau
sidebar:
order: 7
---

< TO-DO! >
8 changes: 8 additions & 0 deletions src/content/docs/guides/options.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Slash Command Options
description: Registering and handling slash command options in DiscordLuau.
sidebar:
order: 5
---

< TO-DO! >
8 changes: 8 additions & 0 deletions src/content/docs/guides/subcommands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Slash Command Subcommands
description: Registering and handling slash command subcommands in DiscordLuau.
sidebar:
order: 6
---

< TO-DO! >

0 comments on commit d2c5ad6

Please sign in to comment.