Merge pull request #1037 from discordeno/11.1.1

v11.1.1
This commit is contained in:
ITOH
2021-06-13 20:48:55 +01:00
committed by GitHub
3 changed files with 16 additions and 5 deletions

View File

@@ -5,13 +5,18 @@ import type { DiscordenoInteractionResponse } from "../../types/discordeno/inter
import { endpoints } from "../../util/constants.ts";
import { snakelize, validateComponents } from "../../util/utils.ts";
// TODO: v12 remove | string
/**
* Send a response to a users slash command. The command data will have the id and token necessary to respond.
* Interaction `tokens` are valid for **15 minutes** and can be used to send followup messages.
*
* NOTE: By default we will suppress mentions. To enable mentions, just pass any mentions object.
*/
export async function sendInteractionResponse(id: bigint, token: string, options: DiscordenoInteractionResponse) {
export async function sendInteractionResponse(
id: bigint | string,
token: string,
options: DiscordenoInteractionResponse
) {
// TODO: add more options validations
if (options.data?.components) validateComponents(options.data?.components);
@@ -37,5 +42,9 @@ export async function sendInteractionResponse(id: bigint, token: string, options
cache.executedSlashCommands.delete(token);
}, 900000);
return await rest.runMethod("post", endpoints.INTERACTION_ID_TOKEN(id, token), snakelize(options));
return await rest.runMethod(
"post",
endpoints.INTERACTION_ID_TOKEN(typeof id === "bigint" ? id : BigInt(id), token),
snakelize(options)
);
}

View File

@@ -46,7 +46,7 @@ const baseMember: Partial<DiscordenoMember> = {
return `<@!${this.id!}>`;
},
get tag() {
return `${this.username!}#${this.discriminator!}`;
return `${this.username!}#${this.discriminator!.toString().padStart(4, "0")}`;
},
// METHODS
@@ -232,7 +232,9 @@ export interface DiscordenoMember extends Omit<User, "discriminator" | "id" | "a
/** Get the nickname or the username if no nickname */
name(guildId: bigint): string;
/** Get the guild member object for the specified guild */
guildMember(guildId: bigint):
guildMember(
guildId: bigint
):
| (Omit<GuildMember, "joinedAt" | "premiumSince" | "roles"> & {
joinedAt?: number;
premiumSince?: number;

View File

@@ -228,7 +228,7 @@ export async function createDiscordenoMessage(data: Message) {
props.authorId = createNewProp(snowflakeToBigint(author.id));
props.isBot = createNewProp(author.bot || false);
props.tag = createNewProp(`${author.username}#${author.discriminator}`);
props.tag = createNewProp(`${author.username}#${author.discriminator.toString().padStart(4, "0")}`);
// Discord doesnt give guild id for getMessage() so this will fill it in
const guildIdFinal =