mjdapi
Version:
Midjourney client using Discord.
182 lines (181 loc) • 7.29 kB
TypeScript
import type { APIActionRowComponent, APIAttachment, APIButtonComponentWithCustomId, APIChannel, APIEmbed, APIMessage, APIMessageActionRowComponent, APIMessageInteraction, APIRole, Snowflake } from "../deps.js";
import { MessageType } from "../deps.js";
import Midjourney from "./Midjourney.js";
import type { InteractionName, UserReference } from "./models.js";
export interface ComponentsSummary {
parentId: Snowflake;
processed: boolean;
label: string;
custom_id: string;
}
export interface SplitedPrompt {
source: string;
prompt: string;
id?: string;
mode?: "fast" | "relaxed" | "fast, stealth" | "relaxed, stealth";
name: string;
completion?: number;
}
export declare function extractPrompt(content: string, id: Snowflake): SplitedPrompt | undefined;
export declare class DiscordMessage implements APIMessage {
#private;
/**
* ID of the message
*/
id: Snowflake;
/**
* ID of the channel the message was sent in
*/
channel_id: Snowflake;
/**
* The author of this message (only a valid user in the case where the message is generated by a user or bot user)
*
* If the message is generated by a webhook, the author object corresponds to the webhook's id,
* username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
author: UserReference;
/**
* Contents of the message
*
* The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field
*
* In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**
*
* See https://support-dev.discord.com/hc/articles/4404772028055
*/
content: string;
/**
* When this message was sent
*/
timestamp: string;
/**
* When this message was edited (or null if never)
*/
edited_timestamp: string | null;
/**
* Whether this was a TTS message
*/
tts: boolean;
/**
* Whether this message mentions everyone
*/
mention_everyone: boolean;
/**
* Users specifically mentioned in the message
*
* The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events
* from text-based guild channels
*
* See https://discord.com/developers/docs/resources/user#user-object
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
mentions: UserReference[];
/**
* Roles specifically mentioned in this message
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
mention_roles: APIRole["id"][];
/**
* Any attached files
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*
* The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field
*
* In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**
*
* See https://support-dev.discord.com/hc/articles/4404772028055
*/
attachments: APIAttachment[];
/**
* Any embedded content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*
* The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field
*
* In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**
*
* See https://support-dev.discord.com/hc/articles/4404772028055
*/
embeds: APIEmbed[];
/**
* Whether this message is pinned
*/
pinned: boolean;
/**
* Type of message
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-types
*/
type: MessageType;
/**
* Message flags combined as a bitfield
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-flags
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
flags?: number;
/**
* Sent if the message is a response to an Interaction
*/
interaction?: APIMessageInteraction;
/**
* Sent if a thread was started from this message
*/
thread?: APIChannel;
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*
* The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field
*
* In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**
*
* See https://support-dev.discord.com/hc/articles/4404772028055
*/
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* The message associated with the `message_reference`
*
* This field is only returned for messages with a `type` of `19` (REPLY).
*
* If the message is a reply but the `referenced_message` field is not present,
* the backend did not attempt to fetch the message that was being replied to,
* so its state is unknown.
*
* If the field exists but is `null`, the referenced message was deleted
*
* See https://discord.com/developers/docs/resources/channel#message-object
*/
referenced_message?: DiscordMessage | null;
prompt?: SplitedPrompt;
constructor(client: Midjourney, source: APIMessage);
get componentsNames(): string[];
get parentInteraction(): InteractionName | "";
getComponents(label: string, label2?: string): APIButtonComponentWithCustomId;
/**
* return if the the Message is upscalable, if an id is provide, will return true only if the requested action had not already been started.
*/
canReroll(): APIButtonComponentWithCustomId | null;
/**
* return if the the Message is upscalable, if an id is provide, will return true only if the requested action had not already been started.
*/
canUpscale(id?: number): APIButtonComponentWithCustomId | null;
/**
* return if the the Message can be varaint, if an id is provide, will return true only if the requested action had not already been started.
*/
canVariant(id?: number): APIButtonComponentWithCustomId | null;
reroll(progress?: (percent: number) => void): Promise<DiscordMessage>;
upscale(id: number, progress?: (percent: number) => void): Promise<DiscordMessage>;
variant(id: number, progress?: (percent: number) => void): Promise<DiscordMessage>;
refresh(): Promise<this>;
download(attachementId: number, dest: string): Promise<{
data: ArrayBufferLike;
file: string;
cached: boolean;
} | null>;
}