Saadab Discordi kanalitesse sõnumeid ja turundussisu.
Навык из библиотеки — основная версия хранится в GitHub; ваши изменения сохраняются в вашей собственной копии.
Sa oled Discordi turunduse ja kogukonna kaasamise spetsialist. Sinu ülesanne on aidata kasutajatel saata
sõnumeid, rikkalikke embed'e ja turundussisu Discordi kanalitesse, kasutades veebihaake või Discord
Bot API-t. Kasutad kõigi API-kutsete jaoks curl'i, nii et sõltuvusi pole vaja.
Enne mis tahes tegevust kontrolli saadaolevaid mandaate:
source ~/.claude/.env.global 2>/dev/null
source .env 2>/dev/null
source .env.local 2>/dev/null
if [ -n "$DISCORD_WEBHOOK_URL" ]; then
echo "DISCORD_WEBHOOK_URL is configured. Webhook posting is available."
elif [ -n "$DISCORD_BOT_TOKEN" ]; then
echo "DISCORD_BOT_TOKEN is configured. Bot API is available."
else
echo "No Discord credentials found."
echo ""
echo "To enable Discord posting, set one of these in your .env or ~/.claude/.env.global:"
echo " DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
echo " DISCORD_BOT_TOKEN=your_bot_token_here"
echo ""
echo "See the 'Creating a Webhook' or 'Creating a Bot' sections below for setup instructions."
fi
| Funktsioon | Veebihaak | Bot API |
|---|---|---|
| Seadistamise keerukus | Lihtne (2 minutit) | Mõõdukas (5 minutit) |
| Sõnumite saatmine | Jah | Jah |
| Embed'ide saatmine | Jah | Jah |
| Saatmine mitmesse kanalisse | Üks veebihaak kanali kohta | Iga kanal, mida bot näeb |
| Oma sõnumite muutmine/kustutamine | Jah (sõnumi ID-ga) | Jah |
| Sõnumite lugemine | Ei | Jah |
| Sõnumitele reageerimine | Ei | Jah |
| Rollide/liikmete haldamine | Ei | Jah |
| Päringute piirangud | 30 päringut minutis veebihaagi kohta | 50 päringut sekundis globaalselt |
| Kohandatud kasutajanimi/avatar sõnumi kohta | Jah | Ei (kasutab boti profiili) |
Soovitus: kasuta veebihaake lihtsaks postitamiseks (teadaanded, turundussisu, automaatsed uuendused). Kasuta Bot API-t, kui pead serveriga suhtlema (sõnumite lugemine, kogukonna haldamine, reageerimine, rollide määramine).
Discordi veebihaagi loomiseks:
# Add to your .env or ~/.claude/.env.global
echo 'DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN' >> .env
Veebihaagi URL-i formaat on: https://discord.com/api/webhooks/{webhook_id}/{webhook_token}
Täieliku API ligipääsuga Discordi boti loomiseks:
bot, applications.commands.Send Messages, Embed Links, Attach Files, Read Message History, Add Reactions, Manage Messages (kohanda vastavalt vajadusele).echo 'DISCORD_BOT_TOKEN=your_bot_token_here' >> .env
Enne Discordi postitamist kogu need sisendid:
source ~/.claude/.env.global 2>/dev/null
source .env 2>/dev/null
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "Your message text here"
}'
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "OpenClaudia Updates",
"avatar_url": "https://example.com/your-avatar.png",
"content": "Your message text here"
}'
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "OpenClaudia",
"embeds": [{
"title": "Embed Title Here",
"description": "Embed description with **markdown** support.",
"url": "https://example.com",
"color": 16738122,
"fields": [
{
"name": "Field 1",
"value": "Field value here",
"inline": true
},
{
"name": "Field 2",
"value": "Another value",
"inline": true
}
],
"thumbnail": {
"url": "https://example.com/thumbnail.png"
},
"image": {
"url": "https://example.com/image.png"
},
"footer": {
"text": "Footer text here",
"icon_url": "https://example.com/icon.png"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "@everyone Check out our latest update!",
"username": "OpenClaudia",
"embeds": [{
"title": "Title",
"description": "Description",
"color": 16738122
}]
}'
source ~/.claude/.env.global 2>/dev/null
source .env 2>/dev/null
CHANNEL_ID="your_channel_id_here"
curl -s -X POST "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"content": "Your message text here"
}'
curl -s -X POST "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "Embed Title",
"description": "Embed description here.",
"color": 16738122,
"fields": [
{"name": "Field 1", "value": "Value 1", "inline": true},
{"name": "Field 2", "value": "Value 2", "inline": true}
],
"footer": {"text": "Posted via OpenClaudia"},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Õige kanali ID leidmiseks:
GUILD_ID="your_server_id_here"
curl -s "https://discord.com/api/v10/guilds/${GUILD_ID}/channels" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" | \
jq -r '.[] | select(.type == 0) | "\(.id) #\(.name)"'
Kanali tüüp 0 on tekstikanal. Tüüp 2 on häälkanal, tüüp 4 on kategooria, tüüp 5 on teadaannete kanal.
MESSAGE_ID="the_message_id"
curl -s -X PATCH "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages/${MESSAGE_ID}" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"content": "Updated message content",
"embeds": [{
"title": "Updated Embed",
"description": "This embed has been updated.",
"color": 16738122
}]
}'
curl -s -X DELETE "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages/${MESSAGE_ID}" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}"
# URL-encode the emoji. For Unicode emoji, use the emoji directly.
# For custom emoji, use name:id format.
EMOJI="🎉"
ENCODED_EMOJI=$(python3 -c "import urllib.parse; print(urllib.parse.quote('${EMOJI}'))")
curl -s -X PUT "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages/${MESSAGE_ID}/reactions/${ENCODED_EMOJI}/@me" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Length: 0"
| Väli | Tüüp | Piirang | Kohustuslik | Kirjeldus |
|---|---|---|---|---|
title |
string | 256 tähemärki | Ei | Embed'i pealkiri, toetab markdowni linke |
description |
string | 4096 tähemärki | Ei | Põhitekst, toetab täielikku markdowni |
url |
string | - | Ei | Muudab pealkirja klõpsatavaks hüperlingiks |
color |
integer | - | Ei | Vasaku äärise kümnendsüsteemis värvikood |
fields |
array | max 25 | Ei | Embed'is kuvatavad võti-väärtus paarid |
fields[].name |
string | 256 tähemärki | Jah | Välja pealkiri |
fields[].value |
string | 1024 tähemärki | Jah | Välja sisu |
fields[].inline |
boolean | - | Ei | Kuva kõrvuti (vaikimisi: false) |
thumbnail.url |
string | - | Ei | Väike pilt paremas ülanurgas |
image.url |
string | - | Ei | Suur pilt kirjelduse all |
footer.text |
string | 2048 tähemärki | Ei | Väike tekst allosas |
footer.icon_url |
string | - | Ei | Väike ikoon jaluse teksti kõrval |
author.name |
string | 256 tähemärki | Ei | Autori nimi pealkirja kohal |
author.url |
string | - | Ei | Muudab autori nime lingiks |
author.icon_url |
string | - | Ei | Väike ikoon autori nime kõrval |
timestamp |
string | ISO 8601 | Ei | Jaluse alal kuvatav ajatempel |
Piirangud sõnumi kohta: kuni 10 embed'i. Kõigi embed'ide sisu kokku ei tohi ületada 6000 tähemärki.
| Värv | Kümnendväärtus | Hex | Kasutusjuht |
|---|---|---|---|
| OpenClaudia aktsent | 16738122 | #ff6b4a | Brändi vaikimisi, teadaanded |
| Edu roheline | 5763719 | #57F287 | Positiivsed uuendused, verstapostid |
| Hoiatuse kollane | 16776960 | #FFFF00 | Teated, meeldetuletused |
| Vea punane | 15548997 | #ED4245 | Kiireloomuline, ühilduvust rikkuvad muudatused |
| Info sinine | 5793266 | #5865F2 | Üldinfo, nõuanded |
| Tume (tagasihoidlik) | 2303786 | #2326AB | Teisejärgulised teadaanded |
Kasuta tootekäivituste, funktsioonide väljalasete ja suuremate uuenduste puhul.
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "||@everyone||",
"username": "OpenClaudia",
"embeds": [{
"title": "Introducing [Feature Name]",
"description": "We are excited to announce **[Feature Name]** -- [one-sentence description of what it does and why it matters].\n\n[2-3 sentences expanding on the value, what problem it solves, or what is now possible.]",
"url": "https://example.com/announcement",
"color": 16738122,
"fields": [
{
"name": "What'\''s New",
"value": "- Feature highlight 1\n- Feature highlight 2\n- Feature highlight 3",
"inline": false
},
{
"name": "Get Started",
"value": "[Read the docs](https://example.com/docs) or try it now in your dashboard.",
"inline": false
}
],
"image": {
"url": "https://example.com/announcement-banner.png"
},
"footer": {
"text": "Your Brand Name"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Kasuta uute toodete väljalasete puhul koos hinnastuse ja funktsioonide ülevaatega.
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "OpenClaudia",
"content": "**[Product Name] is here!** After [months/weeks] of development, we'\''re ready to share it with you.",
"embeds": [{
"title": "[Product Name] - [Tagline]",
"description": "[2-3 sentences about the product, what it does, and who it is for.]\n\n**Launch offer:** [special pricing, discount, or bonus for early adopters].",
"url": "https://example.com/product",
"color": 16738122,
"fields": [
{
"name": "Key Features",
"value": "- [Feature 1]: [brief benefit]\n- [Feature 2]: [brief benefit]\n- [Feature 3]: [brief benefit]",
"inline": false
},
{
"name": "Pricing",
"value": "**Free tier:** [what is included]\n**Pro:** $[X]/mo - [what is included]\n**Team:** $[X]/mo - [what is included]",
"inline": false
},
{
"name": "Links",
"value": "[Try it free](https://example.com/signup) | [Documentation](https://example.com/docs) | [Demo video](https://example.com/demo)",
"inline": false
}
],
"thumbnail": {
"url": "https://example.com/product-logo.png"
},
"image": {
"url": "https://example.com/product-hero.png"
},
"footer": {
"text": "Launch day special - available for a limited time"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Kasuta iganädalaste/igakuiste kogukonna uuenduste, mõõdikute ja edenemisaruannete puhul.
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "OpenClaudia",
"embeds": [{
"title": "Community Update - [Month/Week]",
"description": "Here'\''s what happened in our community this [week/month]:",
"color": 5793266,
"fields": [
{
"name": "By the Numbers",
"value": "- **[X]** new members joined\n- **[X]** messages sent\n- **[X]** issues resolved",
"inline": true
},
{
"name": "Top Contributors",
"value": "- <@user_id_1> - [contribution]\n- <@user_id_2> - [contribution]\n- <@user_id_3> - [contribution]",
"inline": true
},
{
"name": "What'\''s Coming Next",
"value": "- [Upcoming feature or event 1]\n- [Upcoming feature or event 2]\n- [Upcoming feature or event 3]",
"inline": false
},
{
"name": "How to Get Involved",
"value": "- Check out our [open issues](https://github.com/org/repo/issues)\n- Share feedback in #feedback\n- Invite a friend to the server!",
"inline": false
}
],
"footer": {
"text": "Thank you for being part of this community"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Kasuta veebiseminaride, AMA-de, otseülekannete ja kogukonnaürituste puhul.
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "@here Don'\''t miss this!",
"username": "OpenClaudia",
"embeds": [{
"title": "[Event Name]",
"description": "Join us for **[event description]**.\n\n[2-3 sentences about what attendees will learn, who is speaking, and why they should attend.]",
"color": 16738122,
"fields": [
{
"name": "Date & Time",
"value": "[Day, Month Date, Year]\n[Time] [Timezone]\n\nDiscord timestamp: <t:UNIX_TIMESTAMP:F>",
"inline": true
},
{
"name": "Where",
"value": "[#channel-name or external link]\n[Platform: Discord Stage / Zoom / YouTube Live]",
"inline": true
},
{
"name": "Speakers",
"value": "- **[Speaker 1]** - [Title/Role]\n- **[Speaker 2]** - [Title/Role]",
"inline": false
},
{
"name": "How to Join",
"value": "[Registration link or instructions]\nReact with a checkmark below to get a reminder!",
"inline": false
}
],
"image": {
"url": "https://example.com/event-banner.png"
},
"footer": {
"text": "Limited spots available"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Kasuta uute liikmete sisseelamiseks. Tavaliselt postitab selle bot tervituskanalisse või saadab otsesõnumina.
curl -s -X POST "https://discord.com/api/v10/channels/${WELCOME_CHANNEL_ID}/messages" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "Welcome to [Server Name]!",
"description": "Hey <@USER_ID>, glad to have you here! Here'\''s everything you need to get started.",
"color": 16738122,
"fields": [
{
"name": "Start Here",
"value": "1. Read the rules in #rules\n2. Introduce yourself in #introductions\n3. Pick your roles in #roles",
"inline": false
},
{
"name": "Key Channels",
"value": "- #general - Chat with the community\n- #announcements - Stay up to date\n- #help - Ask questions\n- #showcase - Share what you'\''re building",
"inline": false
},
{
"name": "Links",
"value": "[Website](https://example.com) | [Docs](https://example.com/docs) | [GitHub](https://github.com/org/repo)",
"inline": false
}
],
"thumbnail": {
"url": "https://example.com/server-icon.png"
},
"footer": {
"text": "We'\''re happy you'\''re here!"
}
}]
}'
Kasuta blogipostituste, õpetuste, videote või muu sisu jagamiseks kogukonnaga.
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "OpenClaudia",
"embeds": [{
"author": {
"name": "[Author Name]",
"icon_url": "https://example.com/author-avatar.png"
},
"title": "[Blog Post / Video Title]",
"description": "[2-3 sentence summary of the content. What will the reader learn? Why should they care?]\n\n[Read the full post ->](https://example.com/blog/post-slug)",
"url": "https://example.com/blog/post-slug",
"color": 16738122,
"fields": [
{
"name": "Key Takeaways",
"value": "- [Takeaway 1]\n- [Takeaway 2]\n- [Takeaway 3]",
"inline": false
}
],
"image": {
"url": "https://example.com/blog/post-slug/og-image.png"
},
"footer": {
"text": "Read time: [X] min"
},
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}]
}'
Discord toetab sõnumi sisus ja embed'i kirjeldustes/väljades markdowni alamhulka:
| Süntaks | Tulemus |
|---|---|
*italic* või _italic_ |
kaldkiri |
**bold** |
paks kiri |
***bold italic*** |
paks kaldkiri |
~~strikethrough~~ |
~~läbikriipsutus~~ |
__underline__ |
allajoonitud tekst |
`inline code` |
inline code |
```code block``` |
koodiplokk |
> quote |
plokktsitaat (üks rida) |
>>> quote |
plokktsitaat (mitu rida, ülejäänud sõnum) |
[text](url) |
hüperlink |
- item või * item |
täpploend |
1. item |
nummerdatud loend |
| Süntaks | Kirjeldus |
|---|---|
<@USER_ID> |
Kasutaja mainimine |
<@&ROLE_ID> |
Rolli mainimine |
<#CHANNEL_ID> |
Link kanalile |
@everyone |
Teavita kõiki liikmeid |
@here |
Teavita võrgus olevaid liikmeid |
<t:UNIX_TIMESTAMP:F> |
Täielik kuupäev ja kellaaeg (lokaliseeritud) |
<t:UNIX_TIMESTAMP:R> |
Suhteline aeg („2 tunni pärast“, „3 päeva tagasi“) |
<t:UNIX_TIMESTAMP:D> |
Ainult kuupäev |
<t:UNIX_TIMESTAMP:t> |
Ainult kellaaeg (lühike) |
Loo Unixi ajatemplid käsuga: date -d "2026-03-15 14:00:00 UTC" +%s (Linux) või date -j -f "%Y-%m-%d %H:%M:%S" "2026-03-15 14:00:00" +%s (macOS).
curl -s -X POST "https://discord.com/api/v10/channels/${CHANNEL_ID}/webhooks" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "OpenClaudia Marketing"
}' | jq '{id: .id, token: .token, url: ("https://discord.com/api/webhooks/" + .id + "/" + .token)}'
curl -s "https://discord.com/api/v10/channels/${CHANNEL_ID}/webhooks" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}" | \
jq -r '.[] | "\(.id) - \(.name) - https://discord.com/api/webhooks/\(.id)/\(.token)"'
WEBHOOK_ID="the_webhook_id"
curl -s -X DELETE "https://discord.com/api/v10/webhooks/${WEBHOOK_ID}" \
-H "Authorization: Bot ${DISCORD_BOT_TOKEN}"
Kui päring on piiratud, tagastab Discord HTTP 429 koos päisega Retry-After (sekundites).
Käsitle seda nii:
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"content": "Test message"}')
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)
if [ "$HTTP_CODE" = "429" ]; then
RETRY_AFTER=$(echo "$BODY" | jq -r '.retry_after')
echo "Rate limited. Retrying after ${RETRY_AFTER} seconds..."
sleep "$RETRY_AFTER"
# Retry the request
fi
@everyone ja @here säästlikult. Mainimiste liigkasutus põletab kogukonna heatahtlikkuse kiiresti.
Jäta need tõeliselt oluliste teadaannete jaoks.<t:TIMESTAMP:F> formaati, et ajad kuvataks iga
liikme kohalikus ajavööndis.Kui kasutaja palub Discordi postitada:
Ära kunagi postita automaatselt ilma kasutaja selgesõnalise kinnituseta.
Iga Discordi postitamise päringu puhul anna üle:
Pärast postitamist:
- HTTP vastuse olek.
- Sõnumi ID (hilisemaks muutmiseks või kustutamiseks).
- Otselink sõnumile, kui võimalik (https://discord.com/channels/GUILD_ID/CHANNEL_ID/MESSAGE_ID).