SnowTransfer error handling is no longer pathetic

This commit is contained in:
Cadence Ember
2026-08-17 17:30:06 +12:00
parent c0c6419bd1
commit 1dcd5620c4
6 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ async function updatePins(channelID, roomID, convertedTimestamp) {
try {
var discordPins = await discord.snow.channel.getChannelPinnedMessages(channelID)
} catch (e) {
if (e.message === `{"message": "Missing Access", "code": 50001}`) {
if (e.message === "Missing Access") {
return // Discord sends channel pins update events even for channels that the bot can't view/get pins in, just ignore it
}
throw e
+1 -1
View File
@@ -834,7 +834,7 @@ async function messageToEvent(message, guild, options = {}, di) {
invite = await di.snow.invite.getInvite(match[1], {guild_scheduled_event_id: match[2]})
} catch (e) {
// Skip expired/invalid invites and events
if (e.message === `{"message": "Unknown Invite", "code": 10006}`) {
if (e.message === "Unknown Invite") {
break
} else {
throw e
+1 -1
View File
@@ -107,7 +107,7 @@ module.exports = {
try {
messages = await client.snow.channel.getChannelMessages(channel.id, {limit: 100})
} catch (e) {
if (e.message === `{"message": "Missing Access", "code": 50001}`) { // pathetic error handling from SnowTransfer
if (e.message === "Missing Access") {
console.log(`[check missed messages] no permissions to look back in channel ${channel.name} (${channel.id})`)
continue // Sucks.
} else {
@@ -27,7 +27,7 @@ module.exports = async function(db) {
const webhook = affectedWebhooks[counter-1]
await discord.snow.webhook.deleteWebhookToken(webhook.webhook_id, webhook.webhook_token, "Webhook token possibly compromised during 8th May 2026 outage").catch(e => {
if (e.message === `{"message": "Unknown Webhook", "code": 10015}`) {
if (e.message === "Unknown Webhook") {
// OK
} else {
throw e
+1 -1
View File
@@ -45,7 +45,7 @@ async function ensureWebhook(channelID, forceCreate = false) {
async function withWebhook(channelID, callback) {
const webhook = await ensureWebhook(channelID, false)
return callback(webhook).catch(async e => {
if (e.message === `{"message": "Unknown Webhook", "code": 10015}`) { // pathetic error handling from SnowTransfer
if (e.message === "Unknown Webhook") {
// Our webhook is gone. Maybe somebody deleted it, or removed and re-added OOYE from the guild.
const newWebhook = await ensureWebhook(channelID, true)
return callback(newWebhook) // not caught; if the error happens again just throw it instead of looping
+1 -1
View File
@@ -296,7 +296,7 @@ const commands = [{
try {
var invite = await discord.snow.channel.createChannelInvite(channelID)
} catch (e) {
if (e.message === `{"message": "Missing Permissions", "code": 50013}`) {
if (e.message === "Missing Permissions") {
return api.sendEvent(event.room_id, "m.room.message", {
...ctx,
msgtype: "m.text",