Skip to content

Commit

Permalink
make oaf remind people not to talk about farming in the iotm channel (#…
Browse files Browse the repository at this point in the history
…165)

* make oaf remind people not to talk about farming in the iotm channel

* actually make a thread

* month printing

* use `date-fns`

* further streamlining
  • Loading branch information
horrible-little-slime authored Oct 31, 2023
1 parent edab587 commit 3bac0ca
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/subs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { roleMention } from "discord.js";
import { add, closestTo, format } from "date-fns";
import { ThreadAutoArchiveDuration, roleMention } from "discord.js";

import { discordClient } from "./clients/discord.js";
import { config } from "./config.js";

function determineIotmMonthYear() {
const today = new Date();

format(
closestTo(today, [
add(today, { months: 1 }).setDate(1),
add(today, { months: -1 }).setDate(1),
]) ?? today,
"LLLL y",
);
}

export async function rollSubs() {
const guild = await discordClient.guilds.fetch(config.GUILD_ID);
const iotmChannel = guild?.channels.cache.get(config.IOTM_CHANNEL_ID);
Expand All @@ -17,12 +30,20 @@ export async function rollSubs() {
const subRollEmoji =
guild.emojis.cache.find((e) => e.name === "subsRolling") ?? "";

await iotmChannel.send({
const message = await iotmChannel.send({
content: `🚨${subRollEmoji} Attention ${roleMention(
config.SUBSCRIBER_ROLE_ID,
)}! This is an automated message to let you know that subscriptions are now rolling ${subRollEmoji}🚨`,
)}! This is an automated message to let you know that subscriptions are now rolling ${subRollEmoji}🚨
Feel free to discuss spading and speed strats here in the main channel; speculation about farming strategy should be done in the thread.`,
allowedMentions: {
roles: [config.SUBSCRIBER_ROLE_ID],
},
});

await message.startThread({
name: `Farming Discussion for ${determineIotmMonthYear()} IotM`,
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
reason: `to discuss & speculate about farming strategy for the ${determineIotmMonthYear()} IotM`,
});
}

0 comments on commit 3bac0ca

Please sign in to comment.