Skip to content

Commit 5dadf9d

Browse files
committed
Cleanup
1 parent 6f81004 commit 5dadf9d

14 files changed

Lines changed: 53 additions & 73 deletions

src/components/moderation/modstats.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ export default class ModStats extends BotComponent {
6464
await command.reply(`<@${moderator.id}> is not a moderator`);
6565
return;
6666
}
67-
if (
68-
!this.wheatley.is_authorized_mod(command.user) &&
69-
command.channel_id != this.bot_spam.id
70-
) {
67+
if (!this.wheatley.is_authorized_mod(command.user) && command.channel_id != this.bot_spam.id) {
7168
await command.reply(`Please use in <#${this.bot_spam.id}>`, true);
7269
return;
7370
}

src/components/pin-archive.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type pin_archive_entry = {
2828

2929
export default class PinArchive extends BotComponent {
3030
private pin_archive: Discord.TextChannel;
31-
mutex = new KeyedMutexSet<string>;
31+
mutex = new KeyedMutexSet<string>();
3232

3333
private database = this.wheatley.database.create_proxy<{
3434
pins: pin_entry;
@@ -62,9 +62,7 @@ export default class PinArchive extends BotComponent {
6262
// edit
6363
let pin_archive_message;
6464
try {
65-
pin_archive_message = await this.pin_archive.messages.fetch(
66-
pin_archive_entry.archive_message,
67-
);
65+
pin_archive_message = await this.pin_archive.messages.fetch(pin_archive_entry.archive_message);
6866
} catch (e: any) {
6967
// unknown message
7068
if (e instanceof Discord.DiscordAPIError && e.code === 10008) {

src/components/speedrun.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ export default class Speedrun extends BotComponent {
5757
text: `ID: ${user.id}`,
5858
})
5959
.setTimestamp();
60-
this.staff_action_log
61-
.send({ embeds: [embed] })
62-
.catch(this.wheatley.critical_error.bind(this.wheatley));
60+
this.staff_action_log.send({ embeds: [embed] }).catch(this.wheatley.critical_error.bind(this.wheatley));
6361
}
6462
}

src/components/thread-control.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ export default class ThreadControl extends BotComponent {
7272
if (await this.try_to_control_thread(command, "archive")) {
7373
const channel = await command.get_channel();
7474
assert(channel.isThread());
75-
if (
76-
channel.parentId == this.rules.id &&
77-
channel.type == Discord.ChannelType.PrivateThread
78-
) {
75+
if (channel.parentId == this.rules.id && channel.type == Discord.ChannelType.PrivateThread) {
7976
await command.reply("Archiving", true);
8077
await channel.setArchived();
8178
} else {

src/modules/tccpp/components/anti-self-star.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ export default class AntiSelfStar extends BotComponent {
2323
if (reaction.emoji.name !== "⭐") {
2424
return;
2525
}
26-
if (
27-
message.channelId == this.wheatley.channels.memes &&
28-
user.id == message.author.id &&
29-
has_media(message)
30-
) {
26+
if (message.channelId == this.wheatley.channels.memes && user.id == message.author.id && has_media(message)) {
3127
await this.handle_self_star(await departialize(message));
3228
}
3329
}

src/modules/tccpp/components/c-help-redirect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export default class CHelpRedirect extends BotComponent {
6666
// use the same set for both channels, shouldn't be an issue in practice
6767
readonly auto_triggered_users = new SelfClearingSet<string>(1 * HOUR);
6868

69-
private c_help_text!: Discord.TextChannel;
70-
private cpp_help_text!: Discord.TextChannel;
69+
private c_help_text: Discord.TextChannel;
70+
private cpp_help_text: Discord.TextChannel;
7171

7272
override async setup(commands: CommandSetBuilder) {
7373
this.c_help_text = await this.utilities.get_channel(this.wheatley.channels.c_help_text);

src/modules/tccpp/components/days-since-last-incident.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class DaysSinceLastIncident extends BotComponent {
1717
last_time = "";
1818
timer: NodeJS.Timeout;
1919

20-
private days_since_last_incident!: Discord.TextChannel;
20+
private days_since_last_incident: Discord.TextChannel;
2121

2222
private database = this.wheatley.database.create_proxy<{
2323
moderations: moderation_entry;
@@ -28,6 +28,12 @@ export default class DaysSinceLastIncident extends BotComponent {
2828
this.wheatley.event_hub.on("issue_moderation", this.handle_incident.bind(this));
2929
}
3030

31+
override async setup() {
32+
this.days_since_last_incident = await this.utilities.get_channel(
33+
this.wheatley.channels.days_since_last_incident,
34+
);
35+
}
36+
3137
make_embed(incident: incident_info) {
3238
const [count, unit] = incident.time.split(" ");
3339
return new Discord.EmbedBuilder().setColor(0xefd30a).setDescription(
@@ -63,8 +69,6 @@ export default class DaysSinceLastIncident extends BotComponent {
6369
}
6470

6571
override async on_ready() {
66-
this.days_since_last_incident = await this.utilities.get_channel(this.wheatley.channels.days_since_last_incident);
67-
6872
const messages = (await this.days_since_last_incident.messages.fetch()).filter(
6973
message => message.author.id == this.wheatley.user.id,
7074
);

src/modules/tccpp/components/permissions-manager.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,14 @@ export default class PermissionManager extends BotComponent {
349349
}
350350

351351
async add_channel_overwrite(channel: Discord.GuildChannel | string, permissions: permission_overwrites) {
352-
let channelObj: Discord.GuildChannel;
353-
if (typeof channel === 'string') {
354-
channelObj = await this.wheatley.client.channels.fetch(channel) as Discord.GuildChannel;
352+
let channel_obj: Discord.GuildChannel;
353+
if (typeof channel === "string") {
354+
channel_obj = (await this.wheatley.client.channels.fetch(channel)) as Discord.GuildChannel;
355355
} else {
356-
channelObj = channel;
356+
channel_obj = channel;
357357
}
358-
this.channel_overrides[channelObj.id] = {
359-
channel: channelObj,
358+
this.channel_overrides[channel_obj.id] = {
359+
channel: channel_obj,
360360
permissions,
361361
};
362362
}

src/modules/tccpp/components/roulette.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class Roulette extends BotComponent {
2323
// user id -> streak count
2424
readonly streaks = new SelfClearingMap<string, number>(60 * MINUTE);
2525

26-
private staff_member_log!: Discord.TextChannel;
26+
private staff_member_log: Discord.TextChannel;
2727

2828
private database = this.wheatley.database.create_proxy<{
2929
roulette_leaderboard: roulette_leaderboard_entry;

src/modules/tccpp/components/server-suggestion-tracker.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ export default class ServerSuggestionTracker extends BotComponent {
5353
private server_suggestions: Discord.TextChannel;
5454

5555
override async setup(commands: CommandSetBuilder) {
56-
this.suggestion_action_log = await this.wheatley.client.channels.fetch(this.wheatley.channels.suggestion_action_log) as Discord.ThreadChannel;
57-
this.suggestion_dashboard = await this.wheatley.client.channels.fetch(this.wheatley.channels.suggestion_dashboard) as Discord.ThreadChannel;
56+
this.suggestion_action_log = (await this.wheatley.client.channels.fetch(
57+
this.wheatley.channels.suggestion_action_log,
58+
)) as Discord.ThreadChannel;
59+
this.suggestion_dashboard = (await this.wheatley.client.channels.fetch(
60+
this.wheatley.channels.suggestion_dashboard,
61+
)) as Discord.ThreadChannel;
5862
this.server_suggestions = await this.utilities.get_channel(this.wheatley.channels.server_suggestions);
5963
commands.add(
6064
new TextBasedCommandBuilder("suggestions-dashboard-count", EarlyReplyMode.visible)
@@ -256,9 +260,7 @@ export default class ServerSuggestionTracker extends BotComponent {
256260
try {
257261
const entry = unwrap(await this.database.server_suggestions.findOne({ suggestion: message_id }));
258262
M.log("Suggestion deleted", message_id, entry);
259-
const status_message = await this.suggestion_dashboard.messages.fetch(
260-
entry.status_message,
261-
);
263+
const status_message = await this.suggestion_dashboard.messages.fetch(entry.status_message);
262264
this.status_lock.insert(entry.status_message);
263265
await status_message.delete();
264266
await this.database.server_suggestions.deleteOne({ suggestion: message_id });
@@ -273,9 +275,7 @@ export default class ServerSuggestionTracker extends BotComponent {
273275
const hash = xxh3(message.content);
274276
if (hash != entry.hash) {
275277
M.log("Suggestion edited", message.author.tag, message.author.id, message.url);
276-
const status_message = await this.suggestion_dashboard.messages.fetch(
277-
entry.status_message,
278-
);
278+
const status_message = await this.suggestion_dashboard.messages.fetch(entry.status_message);
279279
const quote = await this.make_embeds(message);
280280
await status_message.edit(quote);
281281
entry.hash = hash;
@@ -293,9 +293,7 @@ export default class ServerSuggestionTracker extends BotComponent {
293293
message.author.id,
294294
message.url,
295295
);
296-
const status_message = await this.suggestion_dashboard.messages.fetch(
297-
entry.status_message,
298-
);
296+
const status_message = await this.suggestion_dashboard.messages.fetch(entry.status_message);
299297
const quote = await this.make_embeds(message);
300298
await status_message.edit(quote);
301299
entry.up = up;
@@ -317,9 +315,7 @@ export default class ServerSuggestionTracker extends BotComponent {
317315
if (entry) {
318316
M.log("Suggestion being resolved", [message.id]);
319317
// remove status message
320-
const status_message = await this.suggestion_dashboard.messages.fetch(
321-
entry.status_message,
322-
);
318+
const status_message = await this.suggestion_dashboard.messages.fetch(entry.status_message);
323319
this.status_lock.insert(entry.status_message);
324320
await status_message.delete();
325321
await this.database.server_suggestions.deleteOne({ suggestion: message.id });
@@ -452,9 +448,7 @@ export default class ServerSuggestionTracker extends BotComponent {
452448
if (entry) {
453449
M.debug("Suggestion vote", reaction.emoji.name, [message.id]);
454450
// update message
455-
const status_message = await this.suggestion_dashboard.messages.fetch(
456-
entry.status_message,
457-
);
451+
const status_message = await this.suggestion_dashboard.messages.fetch(entry.status_message);
458452
const quote = await this.make_embeds(message);
459453
await status_message.edit(quote);
460454
if (reaction.emoji.name == "👍") {
@@ -714,8 +708,7 @@ export default class ServerSuggestionTracker extends BotComponent {
714708
// check if the status message was deleted (if we didn't just delete it with resolve_suggestion)
715709
if (
716710
!suggestion_was_resolved &&
717-
(await this.get_message(this.suggestion_dashboard, entry.status_message)) ==
718-
undefined
711+
(await this.get_message(this.suggestion_dashboard, entry.status_message)) == undefined
719712
) {
720713
// just delete from this.database - no longer tracking
721714
M.info(

0 commit comments

Comments
 (0)