-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! > |