Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GuildMember,
GuildMemberFlags,
InteractionType,
Locale,
Role,
RoleFlags,
TextChannel,
Expand Down Expand Up @@ -43,7 +44,12 @@ const roleObject: APIRole = {
permissions: '8',
managed: false,
mentionable: false,
flags: RoleFlags.InPrompt
flags: RoleFlags.InPrompt,
colors: {
primary_color: 0,
secondary_color: 0,
tertiary_color: 0
}
};

const everyoneRoleObject: APIRole = {
Expand All @@ -57,7 +63,12 @@ const everyoneRoleObject: APIRole = {
permissions: '0',
managed: false,
mentionable: false,
flags: RoleFlags.InPrompt
flags: RoleFlags.InPrompt,
colors: {
primary_color: 0,
secondary_color: 0,
tertiary_color: 0
}
};

const guildObject = {
Expand Down Expand Up @@ -232,16 +243,15 @@ const interactionObject: APIApplicationCommandInteraction = {
user: userObject,
token: '',
version: 1,
locale: 'en-US',
guild_locale: 'en-US',
locale: Locale.EnglishUS,
guild_locale: Locale.EnglishUS,
entitlements: [],
app_permissions: '8',
channel: channelObject,
authorizing_integration_owners: {}
authorizing_integration_owners: {},
attachment_size_limit: 8_388_608
};

/* eslint-disable @typescript-eslint/no-unsafe-assignment */

// @ts-expect-error(2674) using protected constructor to test
export const user: User = new User(client, userObject);

Expand All @@ -262,5 +272,3 @@ export const channel2: TextChannel = new TextChannel(guild, channel2Object, clie

// @ts-expect-error(2674) using protected constructor to test
export const interaction: ChatInputCommandInteraction = new ChatInputCommandInteraction(client, interactionObject);

/* eslint-enable @typescript-eslint/no-unsafe-assignment */
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('UserTransformer', () => {
expect((await ts.run('{user(username)}', { user: new UserTransformer(user) })).body).toBe('parbez');
expect((await ts.run('{user(a)}', { user: new UserTransformer(user) })).body).toBe('{user(a)}');
expect((await ts.run('{user(b)}', { user: new UserTransformer(user, { b: (user) => user.defaultAvatarURL }) })).body).toBe(
'https://cdn.discordapp.com/embed/avatars/0.png'
'https://cdn.discordapp.com/embed/avatars/3.png'
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`MemberTransformer > should match the snapshot 1`] = `
"roleIds": "933378013154906142, 933368398996447292",
"roleNames": "., @everyone",
"roles": "<@&933378013154906142> @everyone",
"tag": "parbez#0000",
"tag": "parbez",
"timeoutUntil": "",
"timeoutUntilTimestamp": null,
"topRole": ".",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`UserTransformer > should match the snapshot 1`] = `
"id": "758880890159235083",
"mention": "<@758880890159235083>",
"name": "",
"tag": "parbez#0000",
"tag": "parbez",
"username": "parbez",
}
`;
1 change: 1 addition & 0 deletions packages/tagscript/src/lib/Utils/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const escapeRegex = /(?<!\\)(?<block>[():{|}])/g;
*/
export const asyncFilter = async <T>(values: T[], fn: (t: T) => Awaitable<boolean>) => {
const promises = values.map(fn);
// eslint-disable-next-line @typescript-eslint/await-thenable
const booleans = await Promise.all(promises);
return values.filter((_, index) => booleans[index]);
};
Expand Down