This commit is contained in:
socram03 2022-07-08 16:03:15 -04:00
parent 6ec048e47d
commit 870882313a
5 changed files with 706 additions and 703 deletions

View File

@ -14,6 +14,7 @@ import type {
DiscordIntegration, DiscordIntegration,
DiscordIntegrationDelete, DiscordIntegrationDelete,
DiscordInteraction, DiscordInteraction,
DiscordMemberWithUser,
DiscordMessage, DiscordMessage,
DiscordMessageDelete, DiscordMessageDelete,
DiscordMessageReactionAdd, DiscordMessageReactionAdd,
@ -25,10 +26,9 @@ import type {
// DiscordThreadMemberUpdate, // DiscordThreadMemberUpdate,
// DiscordThreadMembersUpdate, // DiscordThreadMembersUpdate,
DiscordThreadListSync, DiscordThreadListSync,
DiscordUser,
DiscordMemberWithUser,
DiscordWebhookUpdate,
DiscordTypingStart, DiscordTypingStart,
DiscordUser,
DiscordWebhookUpdate,
} from "../discordeno/mod.ts"; } from "../discordeno/mod.ts";
import type { Snowflake } from "./Snowflake.ts"; import type { Snowflake } from "./Snowflake.ts";
@ -136,9 +136,11 @@ export const TYPING_START: RawHandler<DiscordTypingStart> = (session, _shardId,
guildId: payload.guild_id ? payload.guild_id : undefined, guildId: payload.guild_id ? payload.guild_id : undefined,
userId: payload.user_id, userId: payload.user_id,
timestamp: payload.timestamp, timestamp: payload.timestamp,
member: payload.guild_id ? new Member(session, payload.member as DiscordMemberWithUser, payload.guild_id) : undefined member: payload.guild_id
}) ? new Member(session, payload.member as DiscordMemberWithUser, payload.guild_id)
} : undefined,
});
};
export const INTERACTION_CREATE: RawHandler<DiscordInteraction> = (session, _shardId, interaction) => { export const INTERACTION_CREATE: RawHandler<DiscordInteraction> = (session, _shardId, interaction) => {
session.emit("interactionCreate", InteractionFactory.from(session, interaction)); session.emit("interactionCreate", InteractionFactory.from(session, interaction));

View File

@ -33,17 +33,16 @@ export type ComponentBuilder =
/*** /***
* Utility type * Utility type
* */ */
export type ComponentEmoji = { export type ComponentEmoji = {
id: Snowflake; id: Snowflake;
name: string; name: string;
animated?: boolean; animated?: boolean;
}; };
/** /**
* Utility type * Utility type
* */ */
export interface PermissionsOverwrites { export interface PermissionsOverwrites {
id: Snowflake; id: Snowflake;
type: 0 | 1; type: 0 | 1;
@ -63,7 +62,7 @@ export type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
/** /**
* Utility functions * Utility functions
* */ */
export class Util { export class Util {
static formatImageURL(url: string, size: ImageSize = 128, format?: ImageFormat) { static formatImageURL(url: string, size: ImageSize = 128, format?: ImageFormat) {
return `${url}.${format || (url.includes("/a_") ? "gif" : "jpg")}?size=${size}`; return `${url}.${format || (url.includes("/a_") ? "gif" : "jpg")}?size=${size}`;

View File

@ -1,7 +1,7 @@
import type { Model } from "./Base.ts"; import type { Model } from "./Base.ts";
import type { Snowflake } from "../Snowflake.ts"; import type { Snowflake } from "../Snowflake.ts";
import type { Session } from "../Session.ts"; import type { Session } from "../Session.ts";
import type { DiscordMemberWithUser } from "../../discordeno/mod.ts" import type { DiscordMemberWithUser } from "../../discordeno/mod.ts";
import type { ImageFormat, ImageSize } from "../Util.ts"; import type { ImageFormat, ImageSize } from "../Util.ts";
import type { CreateGuildBan, ModifyGuildMember } from "./guilds/Guild.ts"; import type { CreateGuildBan, ModifyGuildMember } from "./guilds/Guild.ts";
import Util from "../Util.ts"; import Util from "../Util.ts";

View File

@ -6,17 +6,17 @@ import type { PermissionsOverwrites } from "../Util.ts";
/** External from vendor */ /** External from vendor */
import { import {
DiscordChannel,
VideoQualityModes,
ChannelTypes, ChannelTypes,
GatewayOpcodes, DiscordChannel,
DiscordInvite, DiscordInvite,
DiscordMessage,
DiscordWebhook,
TargetTypes,
DiscordInviteMetadata, DiscordInviteMetadata,
DiscordListArchivedThreads,
DiscordMessage,
DiscordThreadMember, DiscordThreadMember,
DiscordListArchivedThreads DiscordWebhook,
GatewayOpcodes,
TargetTypes,
VideoQualityModes,
} from "../../discordeno/mod.ts"; } from "../../discordeno/mod.ts";
/** Functions and others */ /** Functions and others */
@ -78,7 +78,7 @@ export abstract class BaseChannel implements Model {
* Represents the options object to create an invitation * Represents the options object to create an invitation
* @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params * @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
*/ */
export interface DiscordInviteOptions { export interface DiscordInviteOptions {
maxAge?: number; maxAge?: number;
maxUses?: number; maxUses?: number;
unique?: boolean; unique?: boolean;
@ -290,7 +290,7 @@ export class TextChannel {
* Represent the options object to create a thread channel * Represent the options object to create a thread channel
* @link https://discord.com/developers/docs/resources/channel#start-thread-without-message * @link https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/ */
export interface ThreadCreateOptions { export interface ThreadCreateOptions {
name: string; name: string;
autoArchiveDuration?: 60 | 1440 | 4320 | 10080; autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
type: 10 | 11 | 12; type: 10 | 11 | 12;
@ -401,7 +401,9 @@ export class GuildChannel extends BaseChannel implements Model {
return ChannelFactory.from(this.session, channel); return ChannelFactory.from(this.session, channel);
} }
async getArchivedThreads(options: Routes.ListArchivedThreads & { type: "public" | "private" | "privateJoinedThreads" }) { async getArchivedThreads(
options: Routes.ListArchivedThreads & { type: "public" | "private" | "privateJoinedThreads" },
) {
let func: (channelId: Snowflake, options: Routes.ListArchivedThreads) => string; let func: (channelId: Snowflake, options: Routes.ListArchivedThreads) => string;
switch (options.type) { switch (options.type) {
@ -454,7 +456,7 @@ export class GuildChannel extends BaseChannel implements Model {
/** /**
* @link https://discord.com/developers/docs/topics/gateway#update-voice-state * @link https://discord.com/developers/docs/topics/gateway#update-voice-state
*/ */
export interface UpdateVoiceState { export interface UpdateVoiceState {
guildId: string; guildId: string;
channelId?: string; channelId?: string;
selfMute: boolean; selfMute: boolean;

View File

@ -1,5 +1,5 @@
import type { Session } from "../../Session.ts"; import type { Session } from "../../Session.ts";
import type { DiscordComponent } from "../../../discordeno/mod.ts" import type { DiscordComponent } from "../../../discordeno/mod.ts";
import type { Component } from "./Component.ts"; import type { Component } from "./Component.ts";
import { ButtonStyles, MessageComponentTypes } from "../../../discordeno/mod.ts"; import { ButtonStyles, MessageComponentTypes } from "../../../discordeno/mod.ts";
import ActionRow from "./ActionRowComponent.ts"; import ActionRow from "./ActionRowComponent.ts";