Skip to content

Commit 91d6e94

Browse files
committed
Backport
1 parent 4a5294e commit 91d6e94

4 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/commands/toggle.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ const togglePoll = async (message: Message) => {
7171
const embed = EmbedBuilder.from(message.embeds[0]);
7272
embed.setColor(colorToUse);
7373

74-
await Promise.all([
75-
message.edit({
76-
embeds: [embed],
77-
}),
78-
]);
74+
await message.edit({
75+
embeds: [embed],
76+
});
7977
};
8078

8179
const toggleSdm = async (message: Message) => {
@@ -87,10 +85,8 @@ const toggleSdm = async (message: Message) => {
8785
const file = isYes ? "no.png" : "yes.png";
8886
toggledEmbed.setThumbnail(`attachment://${file}`);
8987

90-
await Promise.all([
91-
message.edit({
92-
embeds: [toggledEmbed],
93-
files: [`./assets/${file}`],
94-
}),
95-
]);
88+
await message.edit({
89+
embeds: [toggledEmbed],
90+
files: [`./assets/${file}`],
91+
});
9692
};

src/polyfills.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ if (typeof Math.sumPrecise !== "function") {
2727
// https://github.com/tc39/proposal-upsert
2828
if (typeof Map.prototype.getOrInsert === "undefined") {
2929
Map.prototype.getOrInsert = function <K, V>(this: Map<K, V>, key: K, defaultValue: V): V {
30-
if (!this.has(key)) {
31-
this.set(key, defaultValue);
30+
const v = this.get(key);
31+
if (v !== undefined) {
32+
return v;
3233
}
33-
// biome-ignore lint/style/noNonNullAssertion: inserted bevore
34-
return this.get(key)!;
34+
35+
this.set(key, defaultValue);
36+
return defaultValue;
3537
};
3638
}
3739
if (typeof Map.prototype.getOrInsertComputed === "undefined") {
@@ -40,10 +42,13 @@ if (typeof Map.prototype.getOrInsertComputed === "undefined") {
4042
key: K,
4143
callbackFunction: (key: K) => V,
4244
): V {
43-
if (!this.has(key)) {
44-
this.set(key, callbackFunction(key));
45+
const v = this.get(key);
46+
if (v !== undefined) {
47+
return v;
4548
}
46-
// biome-ignore lint/style/noNonNullAssertion: inserted before
47-
return this.get(key)!;
49+
50+
const defaultValue = callbackFunction(key);
51+
this.set(key, defaultValue);
52+
return defaultValue;
4853
};
4954
}

src/service/ban.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async function assignBannedRoles(context: BotContext, user: GuildMember): Promis
152152
return false;
153153
}
154154

155-
const currentRoles = [...user.roles.cache.map(r => r.id)];
155+
const currentRoles = user.roles.cache.map(r => r.id);
156156
let newRoles = [...currentRoles, bannedRole.id].filter(r => r !== context.roles.default.id);
157157

158158
if (user.roles.cache.find(r => r.id === context.roles.gruendervaeter.id)) {
@@ -177,7 +177,7 @@ async function restoreRoles(context: BotContext, user: GuildMember): Promise<boo
177177
return false;
178178
}
179179

180-
const currentRoles = [...user.roles.cache.map(r => r.id)];
180+
const currentRoles = user.roles.cache.map(r => r.id);
181181
let newRoles = [...currentRoles, defaultRole.id].filter(r => r !== context.roles.banned.id);
182182

183183
if (user.roles.cache.find(r => r.id === context.roles.gruendervaeterBanned.id)) {

src/service/purge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function leetTask(context: BotContext) {
4646
);
4747
}
4848

49-
await Promise.all([...membersToKick.map(member => member.kick())]);
49+
await Promise.all(membersToKick.map(member => member.kick()));
5050

5151
await hauptchat.send(`Hab grad ${membersToKick.size} Jocklerinos gekickt ${dabEmote}`);
5252

0 commit comments

Comments
 (0)