Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #41

Merged
merged 19 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-wolves-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"reacord": minor
---

breaking: more descriptive component event types
33 changes: 33 additions & 0 deletions .changeset/many-pets-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"reacord": minor
---

add new descriptive adapter methods

The reacord instance names have been updated, and the old names are now deprecated.

- `send` -> `createChannelMessage`
- `reply` -> `createInteractionReply`

These new methods also accept discord JS options. Usage example:

```ts
// can accept either a channel object or a channel ID
reacord.createChannelMessage(channel)
reacord.createChannelMessage(channel, {
tts: true,
})
reacord.createChannelMessage(channel, {
reply: {
messageReference: "123456789012345678",
failIfNotExists: false,
},
})

reacord.createInteractionReply(interaction)
reacord.createInteractionReply(interaction, {
ephemeral: true,
})
```

These new methods replace the old ones, which are now deprecated.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
"scripts": {
"lint": "run-s --continue-on-error lint:*",
"lint:eslint": "eslint . --fix --cache --cache-file=node_modules/.cache/.eslintcache --report-unused-disable-directives",
"lint:prettier": "prettier . --write --cache --list-different",
"lint:prettier": "prettier . \"**/*.astro\" --write --cache --list-different",
"lint:types": "tsc -b & pnpm -r --parallel run typecheck",
"astro-sync": "pnpm --filter website exec astro sync",
"format": "run-s --continue-on-error format:*",
"format:eslint": "eslint . --report-unused-disable-directives --fix",
"format:prettier": "prettier --cache --write . \"**/*.astro\"",
"test": "vitest",
"build": "pnpm -r run build",
"build:website": "pnpm --filter website... run build",
Expand Down
35 changes: 23 additions & 12 deletions packages/reacord/library/core/component-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,52 @@ export interface ComponentEvent {
*
* @see https://discord.com/developers/docs/resources/channel#message-object
*/
message: MessageInfo
message: ComponentEventMessage

/**
* The channel that this event occurred in.
*
* @see https://discord.com/developers/docs/resources/channel#channel-object
*/
channel: ChannelInfo
channel: ComponentEventChannel

/**
* The user that triggered this event.
*
* @see https://discord.com/developers/docs/resources/user#user-object
*/
user: UserInfo
user: ComponentEventUser

/**
* The guild that this event occurred in.
*
* @see https://discord.com/developers/docs/resources/guild#guild-object
*/
guild?: GuildInfo
guild?: ComponentEventGuild

/** Create a new reply to this event. */
reply(content?: ReactNode): ReacordInstance
reply(
content?: ReactNode,
options?: ComponentEventReplyOptions,
): ReacordInstance

/**
* Create an ephemeral reply to this event, shown only to the user who
* triggered it.
*
* @deprecated Use event.reply(content, { ephemeral: true })
*/
ephemeralReply(content?: ReactNode): ReacordInstance
}

/** @category Component Event */
export interface ChannelInfo {
export interface ComponentEventReplyOptions {
ephemeral?: boolean
tts?: boolean
}

/** @category Component Event */
export interface ComponentEventChannel {
id: string
name?: string
topic?: string
Expand All @@ -55,11 +66,11 @@ export interface ChannelInfo {
}

/** @category Component Event */
export interface MessageInfo {
export interface ComponentEventMessage {
id: string
channelId: string
authorId: string
member?: GuildMemberInfo
member?: ComponentEventGuildMember
content: string
timestamp: string
editedTimestamp?: string
Expand All @@ -70,14 +81,14 @@ export interface MessageInfo {
}

/** @category Component Event */
export interface GuildInfo {
export interface ComponentEventGuild {
id: string
name: string
member: GuildMemberInfo
member: ComponentEventGuildMember
}

/** @category Component Event */
export interface GuildMemberInfo {
export interface ComponentEventGuildMember {
id: string
nick?: string
displayName: string
Expand All @@ -92,7 +103,7 @@ export interface GuildMemberInfo {
}

/** @category Component Event */
export interface UserInfo {
export interface ComponentEventUser {
id: string
username: string
discriminator: string
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/library/core/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ReactNode } from "react"
*/
export interface ReacordInstance {
/** Render some JSX to this instance (edits the message) */
render: (content: ReactNode) => void
render: (content: ReactNode) => ReacordInstance

/** Remove this message */
destroy: () => void
Expand Down
Loading
Loading