Skip to content

Commit

Permalink
fix: safe execute music handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Nov 10, 2023
1 parent 620a00c commit b7b9878
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/bot/events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export const messageCreate: BotEvent = {
const timedMessageDuration = 10000;

if (message.channel instanceof TextChannel && message.author.bot) {
musicBotMessageHandler(message);
try {
await musicBotMessageHandler(message);
} catch (error) {
throw error;
}
}
if (!message.member) return;
if (!message.guild) return;
Expand Down
12 changes: 6 additions & 6 deletions src/services/marquinhosApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error adding to scrobble queue');
throw error;
}
}

Expand All @@ -35,7 +35,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error dispatching scrobble');
throw error;
}
}

Expand All @@ -51,7 +51,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error removing user from scrobble queue');
throw error;
}
}

Expand All @@ -67,7 +67,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error getting top artists');
throw error;
}
}

Expand All @@ -83,7 +83,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error getting top albums');
throw error;
}
}

Expand All @@ -99,7 +99,7 @@ export class MarquinhosApiService {
const { data } = await axios.request(options);
return data;
} catch (error) {
throw new Error('Error getting top tracks');
throw error;
}
}
}

0 comments on commit b7b9878

Please sign in to comment.