From 9c734b5248ad297852125d2113ea78a9597343d1 Mon Sep 17 00:00:00 2001 From: powermaker450 Date: Fri, 17 Jan 2025 12:28:06 -0500 Subject: [PATCH] Send release notes on a new release --- src/contextcommands/contextdel.ts | 3 ++- src/main.ts | 7 +++-- src/storeman/client.ts | 45 ++++++++++++++++++++++++++++--- src/storeman/types.ts | 1 + 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/contextcommands/contextdel.ts b/src/contextcommands/contextdel.ts index 12dfee6..545c7c4 100644 --- a/src/contextcommands/contextdel.ts +++ b/src/contextcommands/contextdel.ts @@ -42,7 +42,8 @@ export async function execute(interaction: ContextMenuCommandInteraction) { if (!dt.getConfessionById(guildId!, targetId)) { return interaction.reply({ - content: "Either that confession wasn't found or you aren't allowed to remove it.", + content: + "Either that confession wasn't found or you aren't allowed to remove it.", ...messageOpts }); } diff --git a/src/main.ts b/src/main.ts index e9db3b6..39545e0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,10 +16,7 @@ * along with this program. If not, see . */ -import { - ChatInputCommandInteraction, - Events -} from "discord.js"; +import { ChatInputCommandInteraction, Events } from "discord.js"; import { BotClient, BOT_TOKEN, deployCommands } from "./bot"; import { commands } from "./commands"; import { StoreMan } from "./storeman"; @@ -34,6 +31,8 @@ const logger = new Logger("Main"); BotClient.once("ready", client => { logger.log(`We're ready! Logged in as ${client.user.tag}`); + + dt.sendReleaseNotes(); }); // Deploy the commands for a new guild diff --git a/src/storeman/client.ts b/src/storeman/client.ts index 9f65133..b171651 100644 --- a/src/storeman/client.ts +++ b/src/storeman/client.ts @@ -26,8 +26,16 @@ import { GuildSettings } from "./types"; import { DATA_DIR } from "./config"; -import { CommandInteraction, Message } from "discord.js"; +import { + bold, + CommandInteraction, + heading, + Message, + TextChannel, + unorderedList +} from "discord.js"; import Logger from "../utils/Logger"; +import { BotClient } from "../bot"; export class StoreMan { public static readonly fullPath: string = @@ -103,7 +111,8 @@ export class StoreMan { this.data.push({ id: guildId, confessions: [], - settings: opts + settings: opts, + versionNote: "v0.1.1" }); this.saveFile(); @@ -127,6 +136,33 @@ export class StoreMan { return null; } + public sendReleaseNotes(): void { + for (const guild of this.data) { + if (!guild.settings.modChannel) { + return; + } + + if (guild.versionNote !== "v0.1.1") { + // TODO: Manual release notes for now + const channel = BotClient.channels.cache.get(guild.settings.modChannel); + const content = + heading("🎉 Release v0.1.1\n") + + unorderedList([ + "No notable changes with this release, just popping in to say hi! :)", + "You'll get updates about future releases right here in the mod channel!" + ]) + + "\n\n" + + bold("Full Changelog: ") + + "https://codeberg.org/powermaker450/confoss/commits/tag/v0.1.1"; + + (channel as TextChannel).send(content).catch(StoreMan.logger.log); + guild.versionNote = "v0.1.1"; + } + } + + this.saveFile(); + } + // Attempts to add a confession. Returns true if the confession is sent, false if otherwise. public addConfession( message: Message, @@ -182,7 +218,10 @@ export class StoreMan { return null; } - public getConfessionById(guildId: string, messageId: string): Confession | null { + public getConfessionById( + guildId: string, + messageId: string + ): Confession | null { for (const guild of this.data) { if (guild.id === guildId) { for (const confession of guild.confessions) { diff --git a/src/storeman/types.ts b/src/storeman/types.ts index df8f8b0..b3d3ddc 100644 --- a/src/storeman/types.ts +++ b/src/storeman/types.ts @@ -44,6 +44,7 @@ export interface GuildSettings { export interface GuildData { id: string; + versionNote?: "v0.1.1"; confessions: Confession[]; settings: GuildSettings; }