A Deno-powered backend service for Plants vs. Zombies: MODDED. [Read-only GitHub mirror] docs.pvzm.net
express typescript expressjs plant deno jspvz pvzm game online backend plants-vs-zombies zombie javascript plants modded vs plantsvszombies openapi pvz noads
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

0.5.1: try to auto-publish messages where possible

Clay 45b0a945 0bf5eb76

+21 -6
+1 -1
README.md
··· 1 - # PVZM Backend ![v0.5.0](https://img.shields.io/badge/version-v0.4.2-darklime) 1 + # PVZM Backend ![v0.5.1](https://img.shields.io/badge/version-v0.5.1-darklime) 2 2 3 3 > A Deno-powered backend service for [Plants vs. Zombies: MODDED](https://github.com/roblnet13/pvz). This service provides APIs for uploading, downloading, listing, favoriting, and reporting user-created _I, Zombie_ levels. 4 4
+1 -1
deno.json
··· 1 1 { 2 - "version": "0.5.0", 2 + "version": "0.5.1", 3 3 "tasks": { 4 4 "dev": "deno run --watch -P=dev --env-file=.env main.ts", 5 5 "start": "deno run -P --env-file=.env main.ts",
+19 -4
modules/logging/discord.ts
··· 1 - import { AttachmentBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder, GatewayIntentBits, TextChannel } from "discord.js"; 1 + import { AttachmentBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, EmbedBuilder, GatewayIntentBits, Message, TextChannel } from "discord.js"; 2 2 import { Buffer } from "node:buffer"; 3 3 4 4 import type { LevelInfo, AdminLevelInfo, LoggingProvider, ReportInfo, AuditLogEntry } from "./types.ts"; ··· 125 125 const deleteButton = new ButtonBuilder().setLabel("Delete Level").setStyle(ButtonStyle.Link).setURL(level.deleteUrl); 126 126 127 127 return new ActionRowBuilder<ButtonBuilder>().addComponents(playButton, downloadButton, editButton, deleteButton); 128 + } 129 + 130 + private async tryPublish(message: Message): Promise<void> { 131 + try { 132 + if (message.channel.type === ChannelType.GuildAnnouncement) { 133 + await message.crosspost(); 134 + } 135 + } catch (error) { 136 + console.error("Discord logging provider: failed to publish message:", error); 137 + } 128 138 } 129 139 130 140 async sendLevelMessage(level: LevelInfo): Promise<string | null> { ··· 136 146 embeds: [this.buildEmbed(level)], 137 147 components: [this.buildPublicUploadButtons(level)], 138 148 }); 149 + await this.tryPublish(message); 139 150 return message.id; 140 151 } catch (error) { 141 152 console.error("Discord logging provider: send failed:", error); ··· 152 163 embeds: [this.buildEmbed(level)], 153 164 components: [this.buildAdminUploadButtons(level)], 154 165 }); 166 + await this.tryPublish(message); 155 167 156 168 // send a link to the admin message in the audit channel 157 169 if (this.auditChannel) { 158 - await this.auditChannel.send(`https://discord.com/channels/${this.adminChannel.guildId}/${this.adminChannel.id}/${message.id}`); 170 + const auditMessage = await this.auditChannel.send(`https://discord.com/channels/${this.adminChannel.guildId}/${this.adminChannel.id}/${message.id}`); 171 + await this.tryPublish(auditMessage); 159 172 } 160 173 161 174 return message.id; ··· 259 272 ? [new AttachmentBuilder(Buffer.from(report.fileAttachment.content), { name: report.fileAttachment.fileName })] 260 273 : []; 261 274 262 - await this.reportChannel.send({ content, files }); 275 + const message = await this.reportChannel.send({ content, files }); 276 + await this.tryPublish(message); 263 277 return true; 264 278 } catch (error) { 265 279 console.error("Discord logging provider: report send failed:", error); ··· 288 302 .setTimestamp() 289 303 .setColor(entry.action === "delete" ? 0xff0000 : entry.action === "feature" ? 0xffd700 : 0x3498db); 290 304 291 - await this.auditChannel.send({ embeds: [embed] }); 305 + const message = await this.auditChannel.send({ embeds: [embed] }); 306 + await this.tryPublish(message); 292 307 return true; 293 308 } catch (error) { 294 309 console.error("Discord logging provider: audit log failed:", error);