use proper invite types

This commit is contained in:
ITOH
2021-04-13 21:58:57 +02:00
parent c85b76cd18
commit c358d4f932
3 changed files with 25 additions and 2 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { InviteCreate } from "../../types/invites/invite_create.ts"; import { CreateChannelInvite } from "../../types/invites/create_channel_invite.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */
export async function createInvite( export async function createInvite(
channelId: string, channelId: string,
options: InviteCreate, options: CreateChannelInvite,
) { ) {
await requireBotChannelPermissions(channelId, ["CREATE_INSTANT_INVITE"]); await requireBotChannelPermissions(channelId, ["CREATE_INSTANT_INVITE"]);
@@ -0,0 +1,18 @@
import { DiscordInviteTargetTypes } from "./invite_target_types.ts";
export interface CreateChannelInvite {
/** Durationi of invite in seconds before expiry, or 0 for never. Between 0 and 604800 (7 days). Default: 86400 (24 hours) */
maxAge?: number;
/** Max number of users or 0 for unlimited. Between 0 and 100. Default: 0 */
maxUses?: number;
/** Whether this invite only grants temporary membership. Default: false */
temporary?: boolean;
/** If true, don't try to reuse simmilar invite (useful for creating many unique one time use invites). Default: false */
unique?: boolean;
/** The type of target for this voice channel invite */
targetType?: DiscordInviteTargetTypes;
/** The id of the user whose stream to display for this invite, required if `target_type` is 1, the user must be streaming in the channel */
targetUserId?: string;
/** The id of the embedded application to open for this invite, required if `target_type` is 2, the application must have the `EMBEDDED` flag */
targetApplicationId?: string;
}
+5
View File
@@ -0,0 +1,5 @@
/** https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types */
export enum DiscordInviteTargetTypes {
Stream = 1,
EmbeddedApplication,
}