Skip to content

Commit

Permalink
Mit error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowfiend committed Nov 4, 2023
1 parent 9cd00e2 commit 67d147c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion discord-scripts/blow-everything-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ export default async function webhookDiscord(
) {
robot.hear(/blow everything up/, async (msg) => {

Check failure on line 22 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `↹` with `··`
const guild = discordClient.guilds.cache.first()

Check failure on line 23 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `↹` with `····`
if (guild === undefined) {

Check failure on line 24 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `↹` with `····`
msg.send("No guild found.")

Check failure on line 25 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹` with `······`
return
}
const channels = await guild.channels.fetch()
const archiveThreshold = weekdaysBefore(moment(), 4)
channels
.filter((channel): channel is TextChannel => channel !== null && channel.isTextBased() && channel.viewable)
.forEach(async channel => {
try {
const { threads } = await channel.threads.fetch()
const threadsWithDates = (await Promise.all(threads.map(async thread => {
const messages = await thread.messages.fetch({limit: 1})
Expand All @@ -39,9 +44,12 @@ export default async function webhookDiscord(
return { thread, lastActivity: moment(lastActivity) }
}))).filter(({ lastActivity }) => lastActivity.isBefore(archiveThreshold))

const message = `Threads to archive:\n- ${threadsWithDates.map(({ thread, lastActivity }) => `${thread.type === ChannelType.GuildPrivateThread ? "[private]" : thread.name}: ${lastActivity.toLocaleString()}`).join("\n- ")}`
const message = `Threads to archive:\n- ${threadsWithDates.map(({ thread, lastActivity }) => `${thread.type === ChannelType.PrivateThread ? "[private]" : thread.name}: ${lastActivity.toLocaleString()}`).join("\n- ")}`
console.log(message)

Check warning on line 48 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
msg.reply(message)
} catch (err) {
console.error(err, (err as any).stack)

Check warning on line 51 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 51 in discord-scripts/blow-everything-up.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}
})
})
}

0 comments on commit 67d147c

Please sign in to comment.