[Node.js] Nodejs์—์„œ Discord Webhook์œผ๋กœ ๋ฉ”์‹œ์ง€ ๋ฐœ์†กํ•˜๊ธฐ

2024. 2. 11. 23:22ใ†ETC/Programming

1. ์›ํ•˜๋Š” ์ฑ„๋„์— ์›นํ›… ์ƒ์„ฑํ•˜๊ธฐ

์ฑ„๋„ > ์„ค์ • > Intgrations > Create Webhook

Copy Webhook URL์œผ๋กœ ์ƒ์„ฑ๋œ ์›นํ›…์˜ URL์„ ๋ณต์‚ฌํ•œ๋‹ค.

 

2. ์ฝ”๋“œ ์ž‘์„ฑ

// PAYMENT_WEBHOOK_URL์— 1๋ฒˆ์—์„œ ๋ณต์‚ฌํ•œ ์›นํ›… URL์„ ์ €์žฅ

const sendDiscordMsg= async () => {
    const paymentWebhook = new Webhook(PAYMENT_WEBHOOK_URL);
    const embed = new MessageBuilder()
      .setTitle('์ œ๋ชฉ')
      .setColor('๋ฉ”์‹œ์ง€ ์ƒ‰์ƒ')
      .setDescription('๋ฉ”์‹œ์ง€ ๋‚ด์šฉ')
      .setTimestamp();

    return await paymentWebhook.send(embed);
}

๋ฉ”์‹œ์ง€ ๋‚ด์šฉ์—๋Š” ๋งˆํฌ๋‹ค์šด ๋ฌธ๋ฒ•์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 

์ถ”๊ฐ€๋กœ ํ•„์š”ํ•œ ์ปดํฌ๋„ŒํŠธ๋‚˜ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์—ฌ๊ธฐ์„œ ํ™•์ธ ๊ฐ€๋Šฅ.

 

๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฉ”์‹œ์ง€ ๋ฐœ์†ก ์„ฑ๊ณต ~!

'ETC > Programming' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Python] Python ๊ฐ€์ƒํ™˜๊ฒฝ (venv) ์•Œ์•„๋ณด๊ธฐ  (0) 2023.08.29
[React] React Hook API (1)  (0) 2020.06.14
[ReactJS] Hook ๊ฐœ๋… ์•Œ์•„๋ณด๊ธฐ  (4) 2020.06.03