Skip to content

Commit

Permalink
stop some console spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Oct 13, 2024
1 parent d824f31 commit be93161
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 9 additions & 6 deletions bot/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ const replaceWithUnix = (arr: DBPlayer[], map: 'nova' | 'aurora') => arr.filter(

const sendNews = async (client: Client, map: 'aurora' | 'nova') => {
const channel = await client.channels.fetch(map == 'nova' ? NOVA.newsChannel : AURORA.newsChannel) as TextChannel
const msgArr = await channel.messages.fetch().then(msgs => msgs.filter(m =>
m.content != "[Original Message Deleted]" &&
!m.content.startsWith("/")
)).catch(e => { console.error(e); return null })

if (!msgArr) return
return sendNewsReq(msgArr, map)
try {
const msgs = await channel.messages.fetch()
return sendNewsReq(msgs.filter(m =>
m.content != "[Original Message Deleted]" &&
!m.content.startsWith("/")
), map)
} catch(_) {
return
}
}

async function sendNewsReq(msgs: Collection<string, Message>, mapName: 'aurora' | 'nova') {
Expand Down
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ for (const file of eventFiles) {

//#region Error Handling
client.on('error', (err: ErrorWithCode) => {
if (err.code != 50013) console.log(err)
const missingAccess = 50001
const missingPerms = 50013

if (missingPerms || missingAccess) return
console.error(err)
})

process.on('unhandledRejection', (err: ErrorWithCode) => console.error('Unhandled promise rejection: ', err))
Expand Down

0 comments on commit be93161

Please sign in to comment.