mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
needs testing
This commit is contained in:
@@ -182,6 +182,17 @@ export async function sendMessage(
|
||||
content.mentions.roles = content.mentions.roles.slice(0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if (content.mentions.repliedUser) {
|
||||
if (
|
||||
!(await botHasChannelPermissions(
|
||||
channelID,
|
||||
[Permissions.READ_MESSAGE_HISTORY],
|
||||
))
|
||||
) {
|
||||
throw new Error(Errors.MISSING_SEND_MESSAGES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const channel = await cacheHandlers.get("channels", channelID);
|
||||
@@ -197,7 +208,13 @@ export async function sendMessage(
|
||||
endpoints.CHANNEL_MESSAGES(channelID),
|
||||
{
|
||||
...content,
|
||||
allowed_mentions: content.mentions,
|
||||
allowed_mentions: content.mentions
|
||||
? {
|
||||
...content.mentions,
|
||||
replied_user: content.mentions.repliedUser === true,
|
||||
}
|
||||
: undefined,
|
||||
message_reference: content.replyMessageID,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@ export async function createMessage(data: MessageCreateOptions) {
|
||||
webhook_id: webhookID,
|
||||
message_reference: messageReference,
|
||||
edited_timestamp: editedTimestamp,
|
||||
referenced_message: referencedMessageID,
|
||||
...rest
|
||||
} = data;
|
||||
|
||||
const message = {
|
||||
...rest,
|
||||
/** The message id of the original message if this message was sent as a reply. If null, the original message was deleted. */
|
||||
referencedMessageID,
|
||||
channelID,
|
||||
guildID: guildID || "",
|
||||
mentions: data.mentions.map((m) => m.id),
|
||||
|
||||
@@ -101,6 +101,8 @@ export interface MessageContent {
|
||||
roles?: string[];
|
||||
/** Array of user_ids to mention (Max size of 100) */
|
||||
users?: string[];
|
||||
/** Should the message author from the original message be mention. By default this is false. */
|
||||
repliedUser?: boolean;
|
||||
};
|
||||
/** The message contents, up to 2000 characters */
|
||||
content?: string;
|
||||
@@ -114,6 +116,8 @@ export interface MessageContent {
|
||||
embed?: Embed;
|
||||
/** JSON encoded body of any additional request fields. */
|
||||
payload_json?: string;
|
||||
/** If you want to send a reply message, provide the original message id here */
|
||||
replyMessageID?: string;
|
||||
}
|
||||
|
||||
export interface GetMessages {
|
||||
|
||||
@@ -154,6 +154,11 @@ export enum MessageTypes {
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2,
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3,
|
||||
CHANNEL_FOLLOW_ADD,
|
||||
GUILD_DISCOVERY_DISQUALIFIED = 14,
|
||||
GUILD_DISCOVERY_REQUALIFIED,
|
||||
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING,
|
||||
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING,
|
||||
REPLY = 19,
|
||||
}
|
||||
|
||||
export enum ActivityTypes {
|
||||
@@ -275,6 +280,8 @@ export interface MessageCreateOptions {
|
||||
message_reference?: Reference;
|
||||
/** The message flags combined like permission bits describe extra features of the message */
|
||||
flags?: 1 | 2 | 4 | 8 | 16;
|
||||
/** The message id of the original message if this message was sent as a reply. If null, the original message was deleted. */
|
||||
referenced_message?: MessageCreateOptions | null;
|
||||
}
|
||||
|
||||
export interface BaseMessageDeletePayload {
|
||||
|
||||
Reference in New Issue
Block a user