add specific error for /news endpoint

This commit is contained in:
Kalidou Diagne
2024-03-06 11:17:58 +00:00
parent 8286c60f6f
commit f16e92b8e4

View File

@@ -14,14 +14,23 @@ const client = new Client({
const rest = new REST({ version: "10" }).setToken(TOKEN)
export const getAnnouncementChannelMessages = async () => {
console.log("Retrieve announcements from discord channel...")
const MESSAGES_URL = `${Routes.channelMessages(GUILD_ID)}?limit=${MESSAGES_LIMIT}`
// If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL permission
const messages = await rest.get(MESSAGES_URL)
return messages
try {
if (!TOKEN) {
return Promise.reject("Discord token is required")
}
if (!GUILD_ID) {
return Promise.reject("Discord guild id is required")
}
console.log("Retrieve announcements from discord channel...")
const MESSAGES_URL = `${Routes.channelMessages(GUILD_ID)}?limit=${MESSAGES_LIMIT}`
// If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL permission
const messages = await rest.get(MESSAGES_URL)
return messages
} catch(err) {
return Promise.reject(err)
}
}
const runDiscordBot = () => {