mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix: fmt
This commit is contained in:
parent
94852eae76
commit
94cfd9805c
4
egg.json
4
egg.json
@ -4,8 +4,8 @@
|
|||||||
"entry": "./mod.ts",
|
"entry": "./mod.ts",
|
||||||
"description": "A brand new bleeding edge non bloated Discord library",
|
"description": "A brand new bleeding edge non bloated Discord library",
|
||||||
"homepage": "https://github.com/oasisjs/biscuit",
|
"homepage": "https://github.com/oasisjs/biscuit",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"releaseType": "patch",
|
"releaseType": "minor",
|
||||||
"unstable": false,
|
"unstable": false,
|
||||||
"unlisted": false,
|
"unlisted": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -170,7 +170,7 @@ export function WEBHOOK_MESSAGE(
|
|||||||
webhookId: Snowflake,
|
webhookId: Snowflake,
|
||||||
token: string,
|
token: string,
|
||||||
messageId: Snowflake,
|
messageId: Snowflake,
|
||||||
options?: { threadId?: Snowflake }
|
options?: { threadId?: Snowflake },
|
||||||
): string {
|
): string {
|
||||||
let url = `/webhooks/${webhookId}/${token}/messages/${messageId}?`;
|
let url = `/webhooks/${webhookId}/${token}/messages/${messageId}?`;
|
||||||
|
|
||||||
@ -369,7 +369,11 @@ export function GUILD_APPLICATION_COMMANDS(appId: Snowflake, guildId: Snowflake,
|
|||||||
return `/applications/${appId}/guilds/${guildId}/commands`;
|
return `/applications/${appId}/guilds/${guildId}/commands`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GUILD_APPLICATION_COMMANDS_PERMISSIONS(appId: Snowflake, guildId: Snowflake, commandId?: Snowflake): string {
|
export function GUILD_APPLICATION_COMMANDS_PERMISSIONS(
|
||||||
|
appId: Snowflake,
|
||||||
|
guildId: Snowflake,
|
||||||
|
commandId?: Snowflake,
|
||||||
|
): string {
|
||||||
if (commandId) return `/applications/${appId}/guilds/${guildId}/commands/${commandId}/permissions`;
|
if (commandId) return `/applications/${appId}/guilds/${guildId}/commands/${commandId}/permissions`;
|
||||||
return `/applications/${appId}/guilds/${guildId}/commands/permissions`;
|
return `/applications/${appId}/guilds/${guildId}/commands/permissions`;
|
||||||
}
|
}
|
||||||
|
@ -201,11 +201,11 @@ export class Session extends EventEmitter {
|
|||||||
return super.emit(event, ...params);
|
return super.emit(event, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editProfile(nick?: string, avatarURL?: string | null ): Promise<User> {
|
async editProfile(nick?: string, avatarURL?: string | null): Promise<User> {
|
||||||
const avatar = avatarURL ? await urlToBase64(avatarURL) : avatarURL;
|
const avatar = avatarURL ? await urlToBase64(avatarURL) : avatarURL;
|
||||||
const user = await this.rest.runMethod<DiscordUser>(this.rest, 'PATCH', Routes.USER(), {
|
const user = await this.rest.runMethod<DiscordUser>(this.rest, "PATCH", Routes.USER(), {
|
||||||
username: nick,
|
username: nick,
|
||||||
avatar: avatar
|
avatar: avatar,
|
||||||
});
|
});
|
||||||
return new User(this, user);
|
return new User(this, user);
|
||||||
}
|
}
|
||||||
@ -273,7 +273,10 @@ export class Session extends EventEmitter {
|
|||||||
return new User(this, user);
|
return new User(this, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
createApplicationCommand(options: CreateApplicationCommand | CreateContextApplicationCommand, guildId?: Snowflake): Promise<DiscordApplicationCommand> {
|
createApplicationCommand(
|
||||||
|
options: CreateApplicationCommand | CreateContextApplicationCommand,
|
||||||
|
guildId?: Snowflake,
|
||||||
|
): Promise<DiscordApplicationCommand> {
|
||||||
return this.rest.runMethod<DiscordApplicationCommand>(
|
return this.rest.runMethod<DiscordApplicationCommand>(
|
||||||
this.rest,
|
this.rest,
|
||||||
"POST",
|
"POST",
|
||||||
@ -353,7 +356,10 @@ export class Session extends EventEmitter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchApplicationCommandPermission(guildId: Snowflake, id: Snowflake): Promise<DiscordGuildApplicationCommandPermissions> {
|
fetchApplicationCommandPermission(
|
||||||
|
guildId: Snowflake,
|
||||||
|
id: Snowflake,
|
||||||
|
): Promise<DiscordGuildApplicationCommandPermissions> {
|
||||||
return this.rest.runMethod<DiscordGuildApplicationCommandPermissions>(
|
return this.rest.runMethod<DiscordGuildApplicationCommandPermissions>(
|
||||||
this.rest,
|
this.rest,
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -41,7 +41,7 @@ export interface AllowedMentions {
|
|||||||
/**
|
/**
|
||||||
* @link https://github.com/denoland/deno_doc/blob/main/lib/types.d.ts
|
* @link https://github.com/denoland/deno_doc/blob/main/lib/types.d.ts
|
||||||
* channelId is optional when creating a reply, but will always be present when receiving an event/response that includes this data model.
|
* channelId is optional when creating a reply, but will always be present when receiving an event/response that includes this data model.
|
||||||
* */
|
*/
|
||||||
export interface CreateMessageReference {
|
export interface CreateMessageReference {
|
||||||
messageId: Snowflake;
|
messageId: Snowflake;
|
||||||
channelId?: Snowflake;
|
channelId?: Snowflake;
|
||||||
@ -82,7 +82,7 @@ export type EmojiResolvable = string | {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A partial {@link User} to represent the author of a message sent by a webhook
|
* A partial {@link User} to represent the author of a message sent by a webhook
|
||||||
* */
|
*/
|
||||||
export interface WebhookAuthor {
|
export interface WebhookAuthor {
|
||||||
id: string;
|
id: string;
|
||||||
username: string;
|
username: string;
|
||||||
@ -108,7 +108,7 @@ export class Message implements Model {
|
|||||||
users: data.mentions?.map((user) => new User(session, user)) ?? [],
|
users: data.mentions?.map((user) => new User(session, user)) ?? [],
|
||||||
roleIds: data.mention_roles ?? [],
|
roleIds: data.mention_roles ?? [],
|
||||||
channels: data.mention_channels?.map((channel) => ChannelFactory.from(session, channel)) ?? [],
|
channels: data.mention_channels?.map((channel) => ChannelFactory.from(session, channel)) ?? [],
|
||||||
}
|
};
|
||||||
|
|
||||||
if (!data.webhook_id) {
|
if (!data.webhook_id) {
|
||||||
this.author = new User(session, data.author);
|
this.author = new User(session, data.author);
|
||||||
@ -335,7 +335,7 @@ export class Message implements Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins this message
|
* Pins this message
|
||||||
* */
|
*/
|
||||||
async pin(): Promise<void> {
|
async pin(): Promise<void> {
|
||||||
await this.session.rest.runMethod<undefined>(
|
await this.session.rest.runMethod<undefined>(
|
||||||
this.session.rest,
|
this.session.rest,
|
||||||
@ -346,7 +346,7 @@ export class Message implements Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpins this message
|
* Unpins this message
|
||||||
* */
|
*/
|
||||||
async unpin(): Promise<void> {
|
async unpin(): Promise<void> {
|
||||||
await this.session.rest.runMethod<undefined>(
|
await this.session.rest.runMethod<undefined>(
|
||||||
this.session.rest,
|
this.session.rest,
|
||||||
@ -487,7 +487,7 @@ export class Message implements Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* same as Message.removeReaction but removes using a unicode emoji
|
* same as Message.removeReaction but removes using a unicode emoji
|
||||||
* */
|
*/
|
||||||
async removeReactionEmoji(reaction: EmojiResolvable): Promise<void> {
|
async removeReactionEmoji(reaction: EmojiResolvable): Promise<void> {
|
||||||
const r = typeof reaction === "string" ? reaction : `${reaction.name}:${reaction.id}`;
|
const r = typeof reaction === "string" ? reaction : `${reaction.name}:${reaction.id}`;
|
||||||
|
|
||||||
|
@ -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 { DiscordUser, UserFlags, PremiumTypes } from "../../discordeno/mod.ts";
|
import type { DiscordUser, PremiumTypes, UserFlags } from "../../discordeno/mod.ts";
|
||||||
import type { ImageFormat, ImageSize } from "../Util.ts";
|
import type { ImageFormat, ImageSize } from "../Util.ts";
|
||||||
import Util from "../Util.ts";
|
import Util from "../Util.ts";
|
||||||
import * as Routes from "../Routes.ts";
|
import * as Routes from "../Routes.ts";
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
import type { Model } from "./Base.ts";
|
import type { Model } from "./Base.ts";
|
||||||
import type { Session } from "../Session.ts";
|
import type { Session } from "../Session.ts";
|
||||||
import type { Snowflake } from "../Snowflake.ts";
|
import type { Snowflake } from "../Snowflake.ts";
|
||||||
import type { DiscordMessageComponents, DiscordEmbed, DiscordMessage, DiscordWebhook, FileContent, WebhookTypes } from "../../discordeno/mod.ts";
|
import type {
|
||||||
|
DiscordEmbed,
|
||||||
|
DiscordMessage,
|
||||||
|
DiscordMessageComponents,
|
||||||
|
DiscordWebhook,
|
||||||
|
FileContent,
|
||||||
|
WebhookTypes,
|
||||||
|
} from "../../discordeno/mod.ts";
|
||||||
import type { WebhookOptions } from "../Routes.ts";
|
import type { WebhookOptions } from "../Routes.ts";
|
||||||
import type { Attachment } from "./Attachment.ts";
|
import type { Attachment } from "./Attachment.ts";
|
||||||
import type { CreateMessage, AllowedMentions } from "./Message.ts";
|
import type { AllowedMentions, CreateMessage } from "./Message.ts";
|
||||||
import Util from "../Util.ts";
|
import Util from "../Util.ts";
|
||||||
import User from "./User.ts";
|
import User from "./User.ts";
|
||||||
import Message from "./Message.ts";
|
import Message from "./Message.ts";
|
||||||
@ -12,7 +19,7 @@ import * as Routes from "../Routes.ts";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params
|
* @link https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params
|
||||||
* */
|
*/
|
||||||
export interface EditWebhookMessage {
|
export interface EditWebhookMessage {
|
||||||
content?: string;
|
content?: string;
|
||||||
embeds?: DiscordEmbed[];
|
embeds?: DiscordEmbed[];
|
||||||
@ -60,7 +67,9 @@ export class Webhook implements Model {
|
|||||||
guildId?: Snowflake;
|
guildId?: Snowflake;
|
||||||
user?: User;
|
user?: User;
|
||||||
|
|
||||||
async execute(options?: WebhookOptions & CreateMessage & { avatarUrl?: string; username?: string }): Promise<(Message | undefined)> {
|
async execute(
|
||||||
|
options?: WebhookOptions & CreateMessage & { avatarUrl?: string; username?: string },
|
||||||
|
): Promise<(Message | undefined)> {
|
||||||
if (!this.token) {
|
if (!this.token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -88,7 +97,7 @@ export class Webhook implements Model {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
return (options?.wait ?? true) ? new Message(this.session, await(message)) : undefined;
|
return (options?.wait ?? true) ? new Message(this.session, await (message)) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch(): Promise<Webhook> {
|
async fetch(): Promise<Webhook> {
|
||||||
@ -127,7 +136,10 @@ export class Webhook implements Model {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editMessage(messageId?: Snowflake, options?: EditWebhookMessage & { threadId?: Snowflake }): Promise<Message> {
|
async editMessage(
|
||||||
|
messageId?: Snowflake,
|
||||||
|
options?: EditWebhookMessage & { threadId?: Snowflake },
|
||||||
|
): Promise<Message> {
|
||||||
if (!this.token) {
|
if (!this.token) {
|
||||||
throw new Error("No token found");
|
throw new Error("No token found");
|
||||||
}
|
}
|
||||||
@ -162,7 +174,7 @@ export class Webhook implements Model {
|
|||||||
ephemeral: attachment.ephemeral,
|
ephemeral: attachment.ephemeral,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Message(this.session, message);
|
return new Message(this.session, message);
|
||||||
|
@ -17,10 +17,8 @@ export class TextInput extends BaseComponent implements TextInputComponent {
|
|||||||
this.placeholder = data.placeholder;
|
this.placeholder = data.placeholder;
|
||||||
this.value = data.value;
|
this.value = data.value;
|
||||||
|
|
||||||
|
|
||||||
this.minLength = data.min_length;
|
this.minLength = data.min_length;
|
||||||
this.maxLength = data.max_length;
|
this.maxLength = data.max_length;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly session: Session;
|
readonly session: Session;
|
||||||
|
@ -23,7 +23,7 @@ import { Snowflake } from "../Snowflake.ts";
|
|||||||
import Util from "../Util.ts";
|
import Util from "../Util.ts";
|
||||||
import * as Routes from "../Routes.ts";
|
import * as Routes from "../Routes.ts";
|
||||||
import WelcomeScreen from "./WelcomeScreen.ts";
|
import WelcomeScreen from "./WelcomeScreen.ts";
|
||||||
import { GuildChannel, ThreadChannel, ReturnThreadsArchive } from "./channels.ts";
|
import { GuildChannel, ReturnThreadsArchive, ThreadChannel } from "./channels.ts";
|
||||||
import ThreadMember from "./ThreadMember.ts";
|
import ThreadMember from "./ThreadMember.ts";
|
||||||
import Member from "./Member.ts";
|
import Member from "./Member.ts";
|
||||||
import Role from "./Role.ts";
|
import Role from "./Role.ts";
|
||||||
@ -320,7 +320,7 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
this.vefificationLevel = data.verification_level;
|
this.vefificationLevel = data.verification_level;
|
||||||
this.defaultMessageNotificationLevel = data.default_message_notifications;
|
this.defaultMessageNotificationLevel = data.default_message_notifications;
|
||||||
this.explicitContentFilterLevel = data.explicit_content_filter;
|
this.explicitContentFilterLevel = data.explicit_content_filter;
|
||||||
this.premiumTier = data.premium_tier
|
this.premiumTier = data.premium_tier;
|
||||||
|
|
||||||
this.members = new Map(
|
this.members = new Map(
|
||||||
data.members?.map((member) => [data.id, new Member(session, { ...member, user: member.user! }, data.id)]),
|
data.members?.map((member) => [data.id, new Member(session, { ...member, user: member.user! }, data.id)]),
|
||||||
@ -628,7 +628,7 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
return result.pruned;
|
return result.pruned;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveThreads(): Promise<Omit<ReturnThreadsArchive, 'hasMore'>> {
|
async getActiveThreads(): Promise<Omit<ReturnThreadsArchive, "hasMore">> {
|
||||||
const { threads, members } = await this.session.rest.runMethod<DiscordListActiveThreads>(
|
const { threads, members } = await this.session.rest.runMethod<DiscordListActiveThreads>(
|
||||||
this.session.rest,
|
this.session.rest,
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import type { Model } from "../Base.ts";
|
import type { Model } from "../Base.ts";
|
||||||
import type { Session } from "../../Session.ts";
|
import type { Session } from "../../Session.ts";
|
||||||
import type {
|
import type { DiscordInteraction, DiscordMessage, DiscordMessageComponents } from "../../../discordeno/mod.ts";
|
||||||
DiscordInteraction,
|
|
||||||
DiscordMessage,
|
|
||||||
DiscordMessageComponents,
|
|
||||||
} from "../../../discordeno/mod.ts";
|
|
||||||
import type CommandInteraction from "./CommandInteraction.ts";
|
import type CommandInteraction from "./CommandInteraction.ts";
|
||||||
import type PingInteraction from "./PingInteraction.ts";
|
import type PingInteraction from "./PingInteraction.ts";
|
||||||
import type ComponentInteraction from "./ComponentInteraction.ts";
|
import type ComponentInteraction from "./ComponentInteraction.ts";
|
||||||
@ -13,7 +9,7 @@ import type AutoCompleteInteraction from "./AutoCompleteInteraction.ts";
|
|||||||
import type { CreateMessage } from "../Message.ts";
|
import type { CreateMessage } from "../Message.ts";
|
||||||
import type { MessageFlags } from "../../Util.ts";
|
import type { MessageFlags } from "../../Util.ts";
|
||||||
import type { EditWebhookMessage } from "../Webhook.ts";
|
import type { EditWebhookMessage } from "../Webhook.ts";
|
||||||
import { InteractionTypes, InteractionResponseTypes } from "../../../discordeno/mod.ts";
|
import { InteractionResponseTypes, InteractionTypes } from "../../../discordeno/mod.ts";
|
||||||
import { Snowflake } from "../../Snowflake.ts";
|
import { Snowflake } from "../../Snowflake.ts";
|
||||||
import User from "../User.ts";
|
import User from "../User.ts";
|
||||||
import Member from "../Member.ts";
|
import Member from "../Member.ts";
|
||||||
@ -22,7 +18,6 @@ import Permsisions from "../Permissions.ts";
|
|||||||
import Webhook from "../Webhook.ts";
|
import Webhook from "../Webhook.ts";
|
||||||
import * as Routes from "../../Routes.ts";
|
import * as Routes from "../../Routes.ts";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
* @link https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||||
*/
|
*/
|
||||||
@ -157,7 +152,7 @@ export abstract class BaseInteraction implements Model {
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
message_id: options.messageId,
|
message_id: options.messageId,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!message || !options.messageId) {
|
if (!message || !options.messageId) {
|
||||||
@ -184,7 +179,7 @@ export abstract class BaseInteraction implements Model {
|
|||||||
token: this.token,
|
token: this.token,
|
||||||
},
|
},
|
||||||
messageId,
|
messageId,
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
@ -194,10 +189,10 @@ export abstract class BaseInteraction implements Model {
|
|||||||
await Webhook.prototype.deleteMessage.call(
|
await Webhook.prototype.deleteMessage.call(
|
||||||
{
|
{
|
||||||
id: this.session.applicationId,
|
id: this.session.applicationId,
|
||||||
token: this.token
|
token: this.token,
|
||||||
},
|
},
|
||||||
messageId,
|
messageId,
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +203,7 @@ export abstract class BaseInteraction implements Model {
|
|||||||
token: this.token,
|
token: this.token,
|
||||||
},
|
},
|
||||||
messageId,
|
messageId,
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
@ -219,7 +214,9 @@ export abstract class BaseInteraction implements Model {
|
|||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
async respond(resp: InteractionResponse): Promise<Message | undefined>;
|
async respond(resp: InteractionResponse): Promise<Message | undefined>;
|
||||||
async respond(resp: { with: InteractionApplicationCommandCallbackData }): Promise<Message | undefined>;
|
async respond(resp: { with: InteractionApplicationCommandCallbackData }): Promise<Message | undefined>;
|
||||||
async respond(resp: InteractionResponse | { with: InteractionApplicationCommandCallbackData }): Promise<Message | undefined> {
|
async respond(
|
||||||
|
resp: InteractionResponse | { with: InteractionApplicationCommandCallbackData },
|
||||||
|
): Promise<Message | undefined> {
|
||||||
const options = "with" in resp ? resp.with : resp.data;
|
const options = "with" in resp ? resp.with : resp.data;
|
||||||
const type = "type" in resp ? resp.type : InteractionResponseTypes.ChannelMessageWithSource;
|
const type = "type" in resp ? resp.type : InteractionResponseTypes.ChannelMessageWithSource;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ export class CommandInteractionOptionResolver {
|
|||||||
properties: Array<keyof CommandInteractionOption>,
|
properties: Array<keyof CommandInteractionOption>,
|
||||||
required: boolean,
|
required: boolean,
|
||||||
): CommandInteractionOption | void {
|
): CommandInteractionOption | void {
|
||||||
const option: (CommandInteractionOption | undefined) = this.get(name, required);
|
const option: CommandInteractionOption | undefined = this.get(name, required);
|
||||||
|
|
||||||
if (!option) {
|
if (!option) {
|
||||||
return;
|
return;
|
||||||
@ -106,7 +106,7 @@ export class CommandInteractionOptionResolver {
|
|||||||
get(name: string | number, required: true): CommandInteractionOption;
|
get(name: string | number, required: true): CommandInteractionOption;
|
||||||
get(name: string | number, required: boolean): CommandInteractionOption | undefined;
|
get(name: string | number, required: boolean): CommandInteractionOption | undefined;
|
||||||
get(name: string | number, required?: boolean) {
|
get(name: string | number, required?: boolean) {
|
||||||
const option: (CommandInteractionOption | undefined) = this.hoistedOptions.find((o) =>
|
const option: CommandInteractionOption | undefined = this.hoistedOptions.find((o) =>
|
||||||
typeof name === "number" ? o.name === name.toString() : o.name === name
|
typeof name === "number" ? o.name === name.toString() : o.name === name
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -125,7 +125,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getString(name: string | number, required: true): string;
|
getString(name: string | number, required: true): string;
|
||||||
getString(name: string | number, required?: boolean): string | undefined;
|
getString(name: string | number, required?: boolean): string | undefined;
|
||||||
getString(name: string | number, required = false) {
|
getString(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.String, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.String,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -134,7 +139,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getNumber(name: string | number, required: true): number;
|
getNumber(name: string | number, required: true): number;
|
||||||
getNumber(name: string | number, required?: boolean): number | undefined;
|
getNumber(name: string | number, required?: boolean): number | undefined;
|
||||||
getNumber(name: string | number, required = false) {
|
getNumber(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Number, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Number,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -143,7 +153,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getInteger(name: string | number, required: true): number;
|
getInteger(name: string | number, required: true): number;
|
||||||
getInteger(name: string | number, required?: boolean): number | undefined;
|
getInteger(name: string | number, required?: boolean): number | undefined;
|
||||||
getInteger(name: string | number, required = false) {
|
getInteger(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Integer, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Integer,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -152,7 +167,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getBoolean(name: string | number, required: true): boolean;
|
getBoolean(name: string | number, required: true): boolean;
|
||||||
getBoolean(name: string | number, required?: boolean): boolean | undefined;
|
getBoolean(name: string | number, required?: boolean): boolean | undefined;
|
||||||
getBoolean(name: string | number, required = false) {
|
getBoolean(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Boolean, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Boolean,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -161,7 +181,9 @@ export class CommandInteractionOptionResolver {
|
|||||||
getUser(name: string | number, required: true): bigint;
|
getUser(name: string | number, required: true): bigint;
|
||||||
getUser(name: string | number, required?: boolean): bigint | undefined;
|
getUser(name: string | number, required?: boolean): bigint | undefined;
|
||||||
getUser(name: string | number, required = false) {
|
getUser(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.User, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(name, ApplicationCommandOptionTypes.User, [
|
||||||
|
"Otherwise",
|
||||||
|
], required);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -170,7 +192,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getChannel(name: string | number, required: true): bigint;
|
getChannel(name: string | number, required: true): bigint;
|
||||||
getChannel(name: string | number, required?: boolean): bigint | undefined;
|
getChannel(name: string | number, required?: boolean): bigint | undefined;
|
||||||
getChannel(name: string | number, required = false) {
|
getChannel(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Channel, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Channel,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -179,7 +206,12 @@ export class CommandInteractionOptionResolver {
|
|||||||
getMentionable(name: string | number, required: true): string;
|
getMentionable(name: string | number, required: true): string;
|
||||||
getMentionable(name: string | number, required?: boolean): string | undefined;
|
getMentionable(name: string | number, required?: boolean): string | undefined;
|
||||||
getMentionable(name: string | number, required = false) {
|
getMentionable(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Mentionable, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Mentionable,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -188,7 +220,9 @@ export class CommandInteractionOptionResolver {
|
|||||||
getRole(name: string | number, required: true): bigint;
|
getRole(name: string | number, required: true): bigint;
|
||||||
getRole(name: string | number, required?: boolean): bigint | undefined;
|
getRole(name: string | number, required?: boolean): bigint | undefined;
|
||||||
getRole(name: string | number, required = false) {
|
getRole(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Role, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(name, ApplicationCommandOptionTypes.Role, [
|
||||||
|
"Otherwise",
|
||||||
|
], required);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
@ -197,14 +231,19 @@ export class CommandInteractionOptionResolver {
|
|||||||
getAttachment(name: string | number, required: true): string;
|
getAttachment(name: string | number, required: true): string;
|
||||||
getAttachment(name: string | number, required?: boolean): string | undefined;
|
getAttachment(name: string | number, required?: boolean): string | undefined;
|
||||||
getAttachment(name: string | number, required = false) {
|
getAttachment(name: string | number, required = false) {
|
||||||
const option: (CommandInteractionOption | void) = this.getTypedOption(name, ApplicationCommandOptionTypes.Attachment, ["Otherwise"], required);
|
const option: CommandInteractionOption | void = this.getTypedOption(
|
||||||
|
name,
|
||||||
|
ApplicationCommandOptionTypes.Attachment,
|
||||||
|
["Otherwise"],
|
||||||
|
required,
|
||||||
|
);
|
||||||
|
|
||||||
return option?.Otherwise ?? undefined;
|
return option?.Otherwise ?? undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** searches for the focused option */
|
/** searches for the focused option */
|
||||||
getFocused(full = false): string | number | bigint | boolean | undefined | CommandInteractionOption {
|
getFocused(full = false): string | number | bigint | boolean | undefined | CommandInteractionOption {
|
||||||
const focusedOption: (CommandInteractionOption | void) = this.hoistedOptions.find((option) => option.focused);
|
const focusedOption: CommandInteractionOption | void = this.hoistedOptions.find((option) => option.focused);
|
||||||
|
|
||||||
if (!focusedOption) {
|
if (!focusedOption) {
|
||||||
throw new TypeError("No option found");
|
throw new TypeError("No option found");
|
||||||
|
@ -2,7 +2,7 @@ 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 { DiscordInteraction, InteractionTypes } from "../../../discordeno/mod.ts";
|
import type { DiscordInteraction, InteractionTypes } from "../../../discordeno/mod.ts";
|
||||||
import { MessageComponentTypes, InteractionResponseTypes } from "../../../discordeno/mod.ts";
|
import { InteractionResponseTypes, MessageComponentTypes } from "../../../discordeno/mod.ts";
|
||||||
import BaseInteraction from "./BaseInteraction.ts";
|
import BaseInteraction from "./BaseInteraction.ts";
|
||||||
import Message from "../Message.ts";
|
import Message from "../Message.ts";
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ import ModalSubmitInteraction from "./ModalSubmitInteraction.ts";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure
|
* @link https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure
|
||||||
* */
|
*/
|
||||||
export interface MessageInteraction {
|
export interface MessageInteraction {
|
||||||
/** id of the interaction */
|
/** id of the interaction */
|
||||||
id: Snowflake;
|
id: Snowflake;
|
||||||
/** type of interaction */
|
/** type of interaction */
|
||||||
type: InteractionTypes
|
type: InteractionTypes;
|
||||||
/** name of the application command, including subcommands and subcommand groups */
|
/** name of the application command, including subcommands and subcommand groups */
|
||||||
name: string
|
name: string;
|
||||||
/** user who invoked the interaction */
|
/** user who invoked the interaction */
|
||||||
user: User;
|
user: User;
|
||||||
/** member who invoked the interaction in the guild */
|
/** member who invoked the interaction in the guild */
|
||||||
@ -49,7 +49,11 @@ export class InteractionFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromMessage(session: Session, interaction: DiscordMessageInteraction, _guildId?: Snowflake): MessageInteraction {
|
static fromMessage(
|
||||||
|
session: Session,
|
||||||
|
interaction: DiscordMessageInteraction,
|
||||||
|
_guildId?: Snowflake,
|
||||||
|
): MessageInteraction {
|
||||||
const obj = {
|
const obj = {
|
||||||
id: interaction.id,
|
id: interaction.id,
|
||||||
type: interaction.type,
|
type: interaction.type,
|
||||||
|
1
packages/cache/Collection.ts
vendored
1
packages/cache/Collection.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import type { Session, Snowflake } from "./deps.ts";
|
import type { Session, Snowflake } from "./deps.ts";
|
||||||
|
|
||||||
export class Collection<V> extends Map<Snowflake, V> {
|
export class Collection<V> extends Map<Snowflake, V> {
|
||||||
|
24
packages/cache/channels.ts
vendored
24
packages/cache/channels.ts
vendored
@ -1,10 +1,4 @@
|
|||||||
import type {
|
import type { ChannelInGuild, ChannelTypes, ChannelWithMessagesInGuild, DiscordChannel, Snowflake } from "./deps.ts";
|
||||||
ChannelInGuild,
|
|
||||||
ChannelWithMessagesInGuild,
|
|
||||||
ChannelTypes,
|
|
||||||
DiscordChannel,
|
|
||||||
Snowflake,
|
|
||||||
} from "./deps.ts";
|
|
||||||
import type { CachedMessage } from "./messages.ts";
|
import type { CachedMessage } from "./messages.ts";
|
||||||
import type { CachedGuild } from "./guilds.ts";
|
import type { CachedGuild } from "./guilds.ts";
|
||||||
import type { SessionCache } from "./mod.ts";
|
import type { SessionCache } from "./mod.ts";
|
||||||
@ -30,9 +24,12 @@ export interface CachedDMChannel extends DMChannel {
|
|||||||
|
|
||||||
export function channelBootstrapper(cache: SessionCache, channel: DiscordChannel) {
|
export function channelBootstrapper(cache: SessionCache, channel: DiscordChannel) {
|
||||||
if (!channel.guild_id) {
|
if (!channel.guild_id) {
|
||||||
cache.dms.set(channel.id, Object.assign(new DMChannel(cache.session, channel), {
|
cache.dms.set(
|
||||||
|
channel.id,
|
||||||
|
Object.assign(new DMChannel(cache.session, channel), {
|
||||||
messages: new Collection<CachedMessage>(cache.session),
|
messages: new Collection<CachedMessage>(cache.session),
|
||||||
}))
|
}),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,24 +44,23 @@ export function channelBootstrapper(cache: SessionCache, channel: DiscordChannel
|
|||||||
guildId: channel.guild_id!,
|
guildId: channel.guild_id!,
|
||||||
get guild(): CachedGuild {
|
get guild(): CachedGuild {
|
||||||
return cache.guilds.get(this.guildId)!;
|
return cache.guilds.get(this.guildId)!;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
guild.channels.set(
|
guild.channels.set(
|
||||||
channel.id,
|
channel.id,
|
||||||
<CachedGuildChannel>Object.assign(
|
<CachedGuildChannel> Object.assign(
|
||||||
ChannelFactory.fromGuildChannel(cache.session, channel),
|
ChannelFactory.fromGuildChannel(cache.session, channel),
|
||||||
{
|
{
|
||||||
guildId: channel.guild_id!,
|
guildId: channel.guild_id!,
|
||||||
get guild(): CachedGuild {
|
get guild(): CachedGuild {
|
||||||
return cache.guilds.get(this.guildId)!;
|
return cache.guilds.get(this.guildId)!;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
packages/cache/guilds.ts
vendored
5
packages/cache/guilds.ts
vendored
@ -1,7 +1,4 @@
|
|||||||
import type {
|
import type { DiscordGuild, DiscordMemberWithUser } from "./deps.ts";
|
||||||
DiscordGuild,
|
|
||||||
DiscordMemberWithUser,
|
|
||||||
} from "./deps.ts";
|
|
||||||
import type { SessionCache } from "./mod.ts";
|
import type { SessionCache } from "./mod.ts";
|
||||||
import type { CachedMember } from "./members.ts";
|
import type { CachedMember } from "./members.ts";
|
||||||
import type { CachedUser } from "./users.ts";
|
import type { CachedUser } from "./users.ts";
|
||||||
|
4
packages/cache/messages.ts
vendored
4
packages/cache/messages.ts
vendored
@ -1,11 +1,11 @@
|
|||||||
import type {
|
import type {
|
||||||
DiscordEmoji,
|
DiscordEmoji,
|
||||||
DiscordMessage,
|
|
||||||
DiscordMemberWithUser,
|
DiscordMemberWithUser,
|
||||||
|
DiscordMessage,
|
||||||
DiscordMessageReactionAdd,
|
DiscordMessageReactionAdd,
|
||||||
DiscordMessageReactionRemove,
|
DiscordMessageReactionRemove,
|
||||||
DiscordMessageReactionRemoveAll,
|
DiscordMessageReactionRemoveAll,
|
||||||
Snowflake
|
Snowflake,
|
||||||
} from "./deps.ts";
|
} from "./deps.ts";
|
||||||
import type { CachedUser } from "./users.ts";
|
import type { CachedUser } from "./users.ts";
|
||||||
import type { SessionCache } from "./mod.ts";
|
import type { SessionCache } from "./mod.ts";
|
||||||
|
6
packages/cache/mod.ts
vendored
6
packages/cache/mod.ts
vendored
@ -7,11 +7,7 @@ import { memberBootstrapper } from "./members.ts";
|
|||||||
import { userBootstrapper } from "./users.ts";
|
import { userBootstrapper } from "./users.ts";
|
||||||
import { channelBootstrapper } from "./channels.ts";
|
import { channelBootstrapper } from "./channels.ts";
|
||||||
import { guildBootstrapper } from "./guilds.ts";
|
import { guildBootstrapper } from "./guilds.ts";
|
||||||
import {
|
import { messageBootstrapper, reactionBootstrapper, reactionBootstrapperDeletions } from "./messages.ts";
|
||||||
messageBootstrapper,
|
|
||||||
reactionBootstrapper,
|
|
||||||
reactionBootstrapperDeletions
|
|
||||||
} from "./messages.ts";
|
|
||||||
|
|
||||||
export const cache_sym = Symbol("@cache");
|
export const cache_sym = Symbol("@cache");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user