fix links, closes #17

This commit is contained in:
itsMapleLeaf
2022-08-04 10:34:09 -05:00
parent 72f4a4afff
commit 38a86bb783
2 changed files with 17 additions and 1 deletions

View File

@@ -353,6 +353,17 @@ function getDiscordMessageOptions(reacordOptions: MessageOptions) {
}
}
if (component.type === "link") {
return {
type: Discord.ComponentType.Button,
url: component.url,
label: component.label ?? "",
style: Discord.ButtonStyle.Link,
disabled: component.disabled,
emoji: component.emoji,
}
}
if (component.type === "select") {
return {
...component,
@@ -364,7 +375,7 @@ function getDiscordMessageOptions(reacordOptions: MessageOptions) {
}
}
raise(`Unsupported component type: ${component.type}`)
raise(`Unsupported component type: ${(component as any).type}`)
},
),
})),

View File

@@ -6,6 +6,7 @@ import * as React from "react"
import { useState } from "react"
import {
Button,
Link,
Option,
ReacordDiscordJs,
Select,
@@ -132,3 +133,7 @@ await createTest("delete this", (channel) => {
}
reacord.send(channel.id, <DeleteThis />)
})
await createTest("link", (channel) => {
reacord.send(channel.id, <Link label="hi" url="https://mapleleaf.dev" />)
})