Skip to content

Commit

Permalink
update/discord-message logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tuturd committed Sep 21, 2024
1 parent b426c15 commit 40b74aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/controllers/order/editStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import PlaceAndDiscord from "../../models/placeAndDiscord";
const sendOrderToDiscordApi = async (order: Order) => {
const token = process.env.DISCORD_API_PRIVATE_KEY;
log.info('Sending order to discord...');
log.info(order);

try {
const discordId: string | null = (await PlaceAndDiscord.findByPk(order.place))?.discordId;
if (!discordId) {
log.info('No discord id found for this place, aborting');
return;
}
log.info(`Discord id found : ${discordId}`);
const res = await axios.post(
`https://discord.com/api/users/@me/channels`,
{ recipient_id: discordId },
Expand All @@ -36,9 +37,9 @@ const sendOrderToDiscordApi = async (order: Order) => {
{ content: "Ta commande est prête, viens la chercher !" },
{ headers: { Authorization: `Bot ${token}` } }
);
log.info('SENT !');
log.info(`Discord message sent to : ${discordId}`);
} catch (error) {
log.warn('Error while sending message to bouffe-discord', error);
log.warn(`Discord message error : ${error}`);
}
};

Expand Down

0 comments on commit 40b74aa

Please sign in to comment.