Skip to content
Open
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: 4 additions & 1 deletion src/classes/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Member as APIMember,
Message as APIMessage,
User as APIUser,
DataCreateInvite,

Check failure on line 10 in src/classes/Channel.ts

View workflow job for this annotation

GitHub Actions / build

Module '"stoat-api"' has no exported member 'DataCreateInvite'.
DataEditChannel,
DataMessageSearch,
DataMessageSend,
Expand Down Expand Up @@ -709,12 +710,14 @@

/**
* Create an invite to the channel
* @param data Invite options
* @requires `TextChannel`
* @returns Newly created invite code
*/
async createInvite(): Promise<Invite> {
async createInvite(data: DataCreateInvite = {}): Promise<Invite> {
return await this.#collection.client.api.post(
`/channels/${this.id as ""}/invites`,
data,
);
}

Expand Down
12 changes: 12 additions & 0 deletions src/classes/Invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class ServerInvite extends ChannelInvite {
readonly creatorId: string;
readonly serverId: string;
readonly channelId: string;
readonly uses?: number;
readonly maxUses?: number;
readonly expires?: Date;

/**
* Construct Server Invite
Expand All @@ -65,6 +68,15 @@ export class ServerInvite extends ChannelInvite {
this.creatorId = invite.creator;
this.serverId = invite.server;
this.channelId = invite.channel;

const { uses, max_uses, expires } = invite as {
uses?: number;
max_uses?: number;
expires?: string;
};
this.uses = uses;
this.maxUses = max_uses;
this.expires = expires ? new Date(expires) : undefined;
}

/**
Expand Down
Loading