Skip to content

Commit 79332da

Browse files
committed
Move operators to start
1 parent 2111bc1 commit 79332da

File tree

44 files changed

+201
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+201
-199
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"useTabs": true,
33
"tabWidth": 4,
4-
"experimentalTernaries": true
4+
"experimentalTernaries": true,
5+
"experimentalOperatorPosition": "start"
56
}

backend/src/branding.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { Permissions } from "oceanic.js";
22

33
export const APP_NAME = "SquirrelBot";
44
export const APP_DESCRIPTION =
5-
"Advanced moderation and management bot created by TheKodeToad.\n" +
6-
"Made in England with Oceanic.js and love!";
5+
"Advanced moderation and management bot created by TheKodeToad.\n"
6+
+ "Made in England with Oceanic.js and love!";
77
export const APP_SOURCE_CODE = "https://github.com/TheKodeToad/SquirrelBot";
88
export const APP_LIBRARIES_LINK =
99
"https://github.com/TheKodeToad/SquirrelBot/blob/develop/backend/package.json";
1010
export const APP_INVITE_PERMISSIONS =
11-
Permissions.VIEW_AUDIT_LOG |
12-
Permissions.KICK_MEMBERS |
13-
Permissions.BAN_MEMBERS |
14-
Permissions.MANAGE_WEBHOOKS |
15-
Permissions.VIEW_CHANNEL |
16-
Permissions.MODERATE_MEMBERS |
17-
Permissions.SEND_MESSAGES |
18-
Permissions.SEND_MESSAGES_IN_THREADS |
19-
Permissions.MANAGE_MESSAGES |
20-
Permissions.EMBED_LINKS |
21-
Permissions.READ_MESSAGE_HISTORY |
22-
Permissions.MUTE_MEMBERS |
23-
Permissions.DEAFEN_MEMBERS;
11+
Permissions.VIEW_AUDIT_LOG
12+
| Permissions.KICK_MEMBERS
13+
| Permissions.BAN_MEMBERS
14+
| Permissions.MANAGE_WEBHOOKS
15+
| Permissions.VIEW_CHANNEL
16+
| Permissions.MODERATE_MEMBERS
17+
| Permissions.SEND_MESSAGES
18+
| Permissions.SEND_MESSAGES_IN_THREADS
19+
| Permissions.MANAGE_MESSAGES
20+
| Permissions.EMBED_LINKS
21+
| Permissions.READ_MESSAGE_HISTORY
22+
| Permissions.MUTE_MEMBERS
23+
| Permissions.DEAFEN_MEMBERS;

backend/src/common/discord/cachedRequest.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export async function fetchMemberCached(
4343
userID: string,
4444
): Promise<Member> {
4545
return (
46-
guild.members.get(userID) ??
47-
(await bot.rest.guilds.getMember(guild.id, userID))
46+
guild.members.get(userID)
47+
?? (await bot.rest.guilds.getMember(guild.id, userID))
4848
);
4949
}
5050

@@ -57,9 +57,8 @@ export async function createDMCached(
5757
userID: string,
5858
): Promise<PrivateChannel> {
5959
return (
60-
bot.privateChannels.find(
61-
(channel) => channel.recipient.id === userID,
62-
) ?? (await bot.rest.users.createDM(userID))
60+
bot.privateChannels.find((channel) => channel.recipient.id === userID)
61+
?? (await bot.rest.users.createDM(userID))
6362
);
6463
}
6564

backend/src/common/discord/formatting.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111

1212
export function formatRESTError(restError: DiscordRESTError): string {
1313
if (
14-
restError.resBody !== null &&
15-
typeof restError.resBody.message === "string"
14+
restError.resBody !== null
15+
&& typeof restError.resBody.message === "string"
1616
) {
1717
return `API Error ${restError.code}: ${escapeMarkdown(restError.resBody.message)}`;
1818
}

backend/src/common/discord/permissions.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export function getHighestRole(member: Member): Role {
2828
}
2929

3030
const QUARANTINE =
31-
GuildMemberFlags.AUTOMOD_QUARANTINED_BIO |
32-
GuildMemberFlags.AUTOMOD_QUARANTINED_CLAN_TAG |
33-
GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME;
31+
GuildMemberFlags.AUTOMOD_QUARANTINED_BIO
32+
| GuildMemberFlags.AUTOMOD_QUARANTINED_CLAN_TAG
33+
| GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME;
3434

3535
export function canWriteInChannel(
3636
bot: Client,
@@ -55,8 +55,8 @@ export function canWriteInChannel(
5555
}
5656

5757
if (
58-
member.communicationDisabledUntil !== null &&
59-
member.communicationDisabledUntil.getTime() >= Date.now()
58+
member.communicationDisabledUntil !== null
59+
&& member.communicationDisabledUntil.getTime() >= Date.now()
6060
) {
6161
return false;
6262
}
@@ -73,21 +73,21 @@ export function canWriteInChannel(
7373
case ChannelTypes.GUILD_VOICE:
7474
case ChannelTypes.GUILD_STAGE_VOICE:
7575
return perms.has(
76-
Permissions.VIEW_CHANNEL |
77-
Permissions.CONNECT |
78-
Permissions.SEND_MESSAGES,
76+
Permissions.VIEW_CHANNEL
77+
| Permissions.CONNECT
78+
| Permissions.SEND_MESSAGES,
7979
);
8080

8181
case ChannelTypes.ANNOUNCEMENT_THREAD:
8282
case ChannelTypes.PUBLIC_THREAD:
8383
case ChannelTypes.PRIVATE_THREAD:
8484
return (
8585
perms.has(
86-
Permissions.VIEW_CHANNEL |
87-
Permissions.SEND_MESSAGES_IN_THREADS,
88-
) &&
89-
(!channel.threadMetadata.locked ||
90-
perms.has(Permissions.MANAGE_THREADS))
86+
Permissions.VIEW_CHANNEL
87+
| Permissions.SEND_MESSAGES_IN_THREADS,
88+
)
89+
&& (!channel.threadMetadata.locked
90+
|| perms.has(Permissions.MANAGE_THREADS))
9191
);
9292

9393
// these channel types can only have messages in child channels

backend/src/common/discord/testing/mockMember.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class MockMember implements Member {
3636

3737
get displayName() {
3838
return (
39-
this._props.displayName ??
40-
this._props.user?.globalName ??
41-
this.nick ??
42-
this.username
39+
this._props.displayName
40+
?? this._props.user?.globalName
41+
?? this.nick
42+
?? this.username
4343
);
4444
}
4545

backend/src/common/pollingScheduler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ async function poll<T>(state: State<T>): Promise<void> {
6464
logger.debug?.(
6565
end.getTime() === 0 ?
6666
`Setting initial timeouts for #${state.options.discriminator} tasks`
67-
: `Setting timeouts for #${state.options.discriminator} tasks` +
68-
` from ${dateToHMSString(state.nextStartTimestamp)}` +
69-
` to ${dateToHMSString(end)}`,
67+
: `Setting timeouts for #${state.options.discriminator} tasks`
68+
+ ` from ${dateToHMSString(state.nextStartTimestamp)}`
69+
+ ` to ${dateToHMSString(end)}`,
7070
);
7171

7272
const tasks = await state.options.poll(state.nextStartTimestamp, end);

backend/src/common/schemas/numberFilter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export const NumberFilter = z.string().transform((input, ctx) => {
3636

3737
if (Number.isNaN(number)) {
3838
ctx.addIssue(
39-
"Invalid value: Expected comparison operator (=, !=, >, >=, <, <=) followed by a number, but received " +
40-
input,
39+
"Invalid value: Expected comparison operator (=, !=, >, >=, <, <=) followed by a number, but received "
40+
+ input,
4141
);
4242
return z.NEVER;
4343
}

backend/src/common/schemas/template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function zTemplate<T extends Shape>(shape: T, allowEscape = true) {
2424
} catch (error) {
2525
if (
2626
!(
27-
error instanceof TemplateCompileError ||
28-
error instanceof TemplateParseError
27+
error instanceof TemplateCompileError
28+
|| error instanceof TemplateParseError
2929
)
3030
) {
3131
throw error;

backend/src/common/time.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export function dateToHMSString(date = new Date()): string {
22
return (
3-
date.getHours().toString().padStart(2, "0") +
4-
":" +
5-
date.getMinutes().toString().padStart(2, "0") +
6-
":" +
7-
date.getSeconds().toString().padStart(2, "0")
3+
date.getHours().toString().padStart(2, "0")
4+
+ ":"
5+
+ date.getMinutes().toString().padStart(2, "0")
6+
+ ":"
7+
+ date.getSeconds().toString().padStart(2, "0")
88
);
99
}
1010

0 commit comments

Comments
 (0)