Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace short hand type conversions with function calls #45

Merged
merged 2 commits into from
Feb 27, 2024
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
9 changes: 6 additions & 3 deletions src/commands/slash/Information/credits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ export default class Credits extends BaseCommand {
{ context: { userId: credit } },
)) as User[];

const member = shardValues.find((m) => !!m) ?? (await interaction.client.users.fetch(credit));
const member =
shardValues.find((m) => Boolean(m)) ?? (await interaction.client.users.fetch(credit));

members.push(member);
}

const linksDivider = `${emojis.blueLine.repeat(9)} **LINKS** ${emojis.blueLine.repeat(9)}`;
const creditsDivider = `${emojis.blueLine.repeat(9)} **TEAM** ${emojis.blueLine.repeat(9)}`;

const creditsEmbed = simpleEmbed(stripIndents`
const creditsEmbed = simpleEmbed(
stripIndents`
## ${emojis.wand} The Team
InterChat is a project driven by a passionate team dedicated to enhancing the Discord experience. We welcome new members to join our team; if you're interested, please join our [support server](${LINKS.SUPPORT_INVITE}).

Expand All @@ -57,7 +59,8 @@ export default class Credits extends BaseCommand {

${linksDivider}
[Guide](${LINKS.DOCS}) • [Invite](https://discord.com/application-directory/769921109209907241) • [Support Server](${LINKS.SUPPORT_INVITE}) • [Vote](https://top.gg/bot/769921109209907241/vote) • [Privacy](${LINKS.DOCS}/legal/privacy) • [Terms](${LINKS.DOCS}/legal/terms)
`.replaceAll('_', '\\_'));
`.replaceAll('_', '\\_'),
);

const linkButtons = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
Expand Down
4 changes: 2 additions & 2 deletions src/core/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default abstract class SuperClient<R extends boolean = boolean> extends C

private readonly scheduler = new Scheduler();

readonly description = 'The only cross-server chatting bot you\'ll ever need.';
readonly description = "The only cross-server chatting bot you'll ever need.";
readonly version = process.env.npm_package_version ?? 'Unknown';
readonly commands = commandsMap;
readonly interactions = interactionsMap;
Expand Down Expand Up @@ -117,7 +117,7 @@ export default abstract class SuperClient<R extends boolean = boolean> extends C

// eslint-disable-next-line @typescript-eslint/no-explicit-any
static resolveEval = <T>(value: T[]) =>
value?.find((res) => !!res) as RemoveMethods<T> | undefined;
value?.find((res) => Boolean(res)) as RemoveMethods<T> | undefined;

/**
* Fetches a guild by its ID from the cache.
Expand Down
8 changes: 4 additions & 4 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const hasVoted = async (userId: Snowflake): Promise<boolean> => {
})
).json();

return !!res.voted;
return Boolean(res.voted);
};

export const userVotedToday = async (userId: Snowflake): Promise<boolean> => {
Expand Down Expand Up @@ -156,8 +156,8 @@ export const disableAllComponents = (
const jsonRow = row.toJSON();
jsonRow.components.forEach((component) => {
!disableLinks &&
component.type === ComponentType.Button &&
component.style === ButtonStyle.Link
component.type === ComponentType.Button &&
component.style === ButtonStyle.Link
? (component.disabled = false) // leave link buttons enabled
: (component.disabled = true);
});
Expand Down Expand Up @@ -351,7 +351,7 @@ export const parseEmoji = (emoji: string) => {
if (!match) return null;

const [, animated, name, id] = match;
return { animated: !!animated, name, id };
return { animated: Boolean(animated), name, id };
};

export const getEmojiId = (emoji: string | undefined) => {
Expand Down