SKILL.md
readonly只读
name
discord-bot
description
Discord机器人开发——社区管理、审核、通知和AI集成
version
1.0.0
Discord Bot
构建用于社区管理、审核、通知和AI集成的Discord机器人。基于n8n的Discord工作流模板。
概述
本技能涵盖:
- 机器人设置与配置
- 斜杠命令与交互
- 审核自动化
- 通知工作流
- AI驱动功能
机器人设置
创建Discord机器人
setup_steps:
1. create_application:
url: https://discord.com/developers/applications
action: "新建应用"
2. create_bot:
section: "Bot"
action: "添加Bot"
copy: token
3. configure_intents:
enable:
- PRESENCE_INTENT
- SERVER_MEMBERS_INTENT
- MESSAGE_CONTENT_INTENT
4. invite_bot:
section: "OAuth2 > URL生成器"
scopes: [bot, applications.commands]
permissions: [根据需求]
generate: invite_link
斜杠命令
slash_commands:
- name: help
description: "显示机器人帮助"
- name: ping
description: "检查机器人延迟"
- name: poll
description: "创建投票"
options:
- name: question
type: STRING
required: true
- name: options
type: STRING
required: true
- name: remind
description: "设置提醒"
options:
- name: time
type: STRING
required: true
- name: message
type: STRING
required: true
审核机器人
自动审核
auto_moderation:
spam_detection:
triggers:
- repeated_messages: 5_in_10_seconds
- mass_mentions: more_than_5
- link_spam: multiple_links_no_text
actions:
- delete_messages
- timeout: 5_minutes
- log_to_mod_channel
word_filter:
blocked_words: [list_of_words]
action:
- delete_message
- warn_user
link_filter:
allowed_domains: [youtube.com, github.com]
action: delete_if_not_allowed
raid_protection:
triggers:
- join_rate: 10_per_minute
actions:
- enable_verification
- notify_mods
- slow_mode: enable
审核命令
mod_commands:
/warn:
permission: MODERATE_MEMBERS
action: |
1. 记录警告
2. 私信用户并说明原因
3. 记录到审核频道
/timeout:
permission: MODERATE_MEMBERS
options: [user, duration, reason]
action: |
1. 应用超时
2. 私信用户
3. 记录操作
/ban:
permission: BAN_MEMBERS
options: [user, reason, delete_messages]
action: |
1. 封禁用户
2. 记录到审核频道
3. 可选:发布到#bans频道
/warnings:
permission: MODERATE_MEMBERS
action: show_user_warning_history
社区功能
欢迎系统
welcome_system:
on_member_join:
actions:
- assign_role: "新成员"
- send_dm:
template: |
👋 欢迎来到{server_name}!
开始步骤:
1. 阅读#rules
2. 在#roles领取身份组
3. 在#introductions自我介绍
需要帮助?请在#support提问
- post_welcome:
channel: "#welcome"
template: |
🎉 欢迎{user_mention}加入服务器!
他们是第#{member_count}位成员
on_member_leave:
channel: "#logs"
template: "{user}离开了服务器。停留时长:{time_since_join}"
身份组管理
reaction_roles:
channel: "#roles"
message: |
点击表情获取身份组:
🎮 - 游戏玩家
💻 - 开发者
🎨 - 艺术家
📚 - 学生
mappings:
"🎮": role_id_gamer
"💻": role_id_developer
"🎨": role_id_artist
"📚": role_id_student
level_roles:
system: xp_based
roles:
- level: 5
role: "活跃成员"
- level: 10
role: "常客"
- level: 25
role: "老成员"
- level: 50
role: "传奇"
工单系统
ticket_system:
create_ticket:
trigger: button_click OR /ticket
action:
- create_channel: "ticket-{user}-{number}"
- set_permissions: [user, support_team]
- send_initial_message:
template: |
🎫 **支持工单**
用户:{user_mention}
创建时间:{timestamp}
请描述您的问题,团队成员将尽快协助您。
点击✅关闭此工单。
close_ticket:
trigger: reaction OR /close
action:
- save_transcript: to_logs_channel
- delete_channel: after_5_seconds
- dm_user: transcript_link
通知工作流
n8n集成
workflow: "Discord通知"
triggers:
github_release:
action:
channel: "#releases"
embed:
title: "🚀 新版本发布:{version}"
description: "{release_notes}"
color: 0x00ff00
fields:
- name: "下载"
value: "[链接]({download_url})"
twitch_live:
action:
channel: "#streams"
message: "@everyone {streamer}正在直播!"
embed:
title: "{stream_title}"
image: "{thumbnail}"
youtube_video:
action:
channel: "#videos"
embed:
title: "{video_title}"
description: "{description}"
thumbnail: "{thumbnail}"
定时发布
scheduled_posts:
daily_question:
schedule: "每天上午10点"
channel: "#daily-discussion"
template: |
🤔 **每日一问**
{random_question}
在下方分享你的想法!👇
weekly_recap:
schedule: "周日下午6点"
channel: "#announcements"
template: |
📊 **每周服务器回顾**
新成员:{new_members}
消息数:{message_count}
最活跃频道:{top_channel}
贡献最多:{top_user}
感谢你成为我们社区的一员!❤️
AI集成
AI聊天机器人
ai_bot:
trigger: mention OR dm
configuration:
model: gpt-4
system_prompt: |
你是一个有用的Discord机器人助手。
- 保持友好,使用适合Discord的语言
- 自然使用表情符号
- 回复简洁
- 帮助解答与服务器相关的问题
features:
- conversation_memory: per_channel
- rate_limiting: 10_per_minute
- content_filter: enabled
commands:
/ask:
description: "向AI提问"
action: ai_response
/summarize:
description: "总结最近的消息"
action: summarize_channel_history
图像生成
image_generation:
command: /imagine
options:
- prompt: STRING (必填)
- style: CHOICE [realistic, anime, cartoon, abstract]
- size: CHOICE [square, portrait, landscape]
workflow:
1. receive_command
2. send_generating_message
3. call_dalle_api
4. send_result_with_buttons:
- Regenerate
- Upscale
- Variations
嵌入与组件
富嵌入
embed:
title: "服务器信息"
description: "欢迎来到我们的社区!"
color: 0x5865F2 # Discord blurple
thumbnail:
url: "{server_icon}"
fields:
- name: "📊 成员"
value: "{member_count}"
inline: true
- name: "💬 频道"
value: "{channel_count}"
inline: true
- name: "🎭 身份组"
value: "{role_count}"
inline: true
- name: "📅 创建时间"
value: "{creation_date}"
inline: false
footer:
text: "最后更新"
icon_url: "{bot_avatar}"
timestamp: "{current_time}"
按钮组件
buttons:
row_1:
- type: button
style: primary
label: "接受规则"
custom_id: "accept_rules"
- type: button
style: secondary
label: "查看规则"
custom_id: "view_rules"
row_2:
- type: button
style: link
label: "网站"
url: "https://example.com"
- type: button
style: danger
label: "离开"
custom_id: "leave_confirm"
输出示例
请求:"创建一个Discord欢迎机器人"
输出:
# Discord欢迎机器人
## 配置
```yaml
events:
- guildMemberAdd
- guildMemberRemove
欢迎消息
// 成员加入时
const welcomeEmbed = {
title: '👋 欢迎来到服务器!',
description: `Hey ${member.user}, welcome to **${guild.name}**!`,
color: 0x00ff00,
fields: [
{ name: '📜 规则', value: '查看<#rules-channel>', inline: true },
{ name: '🎭 身份组', value: '在<#roles>领取身份组', inline: true },
{ name: '💬 聊天', value: '在<#general>打个招呼', inline: true }
],
thumbnail: { url: member.user.displayAvatarURL() },
footer: { text: `Member #${guild.memberCount}` }
};
welcomeChannel.send({ embeds: [welcomeEmbed] });
自动身份组
// 分配"新成员"身份组
await member.roles.add(newMemberRole);
私信欢迎
// 发送包含服务器信息的私信
await member.send({
content: `Welcome to ${guild.name}! Here's everything you need to know...`,
embeds: [infoEmbed]
});
n8n工作流
trigger: Discord - 成员加入时
actions:
- Discord - 发送频道消息(欢迎)
- Discord - 添加身份组
- Discord - 发送私信
- Google Sheets - 记录新成员
---
*Discord机器人技能——Claude Office Skills的一部分*






