This commit is contained in:
Skillz
2020-11-16 23:28:49 -05:00
parent 7f2538f93c
commit bd6c89fdd6
3 changed files with 21 additions and 12 deletions
+4 -2
View File
@@ -211,10 +211,12 @@ export async function sendMessage(
allowed_mentions: content.mentions allowed_mentions: content.mentions
? { ? {
...content.mentions, ...content.mentions,
replied_user: content.mentions.repliedUser === true, replied_user: content.mentions.repliedUser !== false,
} }
: undefined, : undefined,
message_reference: content.replyMessageID, message_reference: {
message_id: content.replyMessageID,
}
}, },
); );
+16 -9
View File
@@ -321,29 +321,36 @@ function handleStatusCode(response: Response, errorStack?: unknown) {
switch (status) { switch (status) {
case HttpResponseCode.BadRequest: case HttpResponseCode.BadRequest:
throw new Error( console.error(
"The request was improperly formatted, or the server couldn't understand it.", "The request was improperly formatted, or the server couldn't understand it.",
); );
throw errorStack;
case HttpResponseCode.Unauthorized: case HttpResponseCode.Unauthorized:
throw new Error("The Authorization header was missing or invalid."); console.error("The Authorization header was missing or invalid.");
throw errorStack;
case HttpResponseCode.Forbidden: case HttpResponseCode.Forbidden:
throw new Error( console.error(
"The Authorization token you passed did not have permission to the resource.", "The Authorization token you passed did not have permission to the resource.",
); );
throw errorStack;
case HttpResponseCode.NotFound: case HttpResponseCode.NotFound:
throw new Error("The resource at the location specified doesn't exist."); console.error("The resource at the location specified doesn't exist.");
throw errorStack;
case HttpResponseCode.MethodNotAllowed: case HttpResponseCode.MethodNotAllowed:
throw new Error( console.error(
"The HTTP method used is not valid for the location specified.", "The HTTP method used is not valid for the location specified.",
); );
throw errorStack;
case HttpResponseCode.GatewayUnavailable: case HttpResponseCode.GatewayUnavailable:
throw new Error( console.error(
"There was not a gateway available to process your request. Wait a bit and retry.", "There was not a gateway available to process your request. Wait a bit and retry.",
); );
throw errorStack;
// left are all unknown
default:
console.error(Errors.REQUEST_UNKNOWN_ERROR);
throw errorStack;
} }
// left are all unknown
throw new Error(Errors.REQUEST_UNKNOWN_ERROR);
} }
function processHeaders(url: string, headers: Headers) { function processHeaders(url: string, headers: Headers) {
+1 -1
View File
@@ -101,7 +101,7 @@ export interface MessageContent {
roles?: string[]; roles?: string[];
/** Array of user_ids to mention (Max size of 100) */ /** Array of user_ids to mention (Max size of 100) */
users?: string[]; users?: string[];
/** Should the message author from the original message be mention. By default this is false. */ /** Should the message author from the original message be mention. By default this is true. */
repliedUser?: boolean; repliedUser?: boolean;
}; };
/** The message contents, up to 2000 characters */ /** The message contents, up to 2000 characters */