AGENT SKILL

discord

Discord Bot integration for sending messages, managing channels, and responding to events. Use when Bub needs to: (1) Send messages to Discord channels, (2) Create Discord bot with discord.py, (3) Handle Discord events (on_message, on_member_join, etc.), (4) Work with Discord webhooks, or (5) Any Discord-related functionality.

License 许可
Apache-2.0
最近更新
2026-11-11
Stars
★ 19
Forks
23

01 前言 Front Matter

name
discord
metadata
{ "channel": "discord" }
description
Discord Bot integration for sending messages, managing channels, and responding to events. Use when Bub needs to: (1) Send messages to Discord channels, (2) Create Discord bot with discord.py, (3) Handle Discord events (on_message, on_member_join, etc.), (4) Work with Discord webhooks, or (5) Any Discord-related functionality.

02 资源文件 2

03 SKILL.md 正文

Discord Bot Skill

Send messages and interact with Discord using discord.py.

Response Contract (Important)

When the user asks to send or draft a Discord message:

  • Return only the final message content intended for Discord.
  • Do not include action narration or meta text such as:
    • "I already prepared..."
    • "I can switch to another version..."
    • "If you want, I can..."
  • Do not prepend or append explanatory wrappers around the message body.
  • If a style is requested (short, technical, casual), apply it directly in the final message.
  • Keep the message concise unless the user explicitly requests detail.

Quick Start

# Dependencies are declared in each script via PEP 723.
# Paths are relative to this skill directory.
# Run scripts directly with uv; it will resolve dependencies from the script header.
uv run ./scripts/discord_send.py --help
uv run ./scripts/discord_bot.py

Sending Messages

Basic Message

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
    channel = bot.get_channel(CHANNEL_ID)
    await channel.send("Hello from Bub!")

Send to Channel by ID

channel = bot.get_channel(123456789)
await channel.send("Message")

Send to Thread

thread = bot.get_channel(THREAD_ID)
await thread.send("Message in thread")

Embed Message

embed = discord.Embed(
    title="Title",
    description="Description",
    color=discord.Color.blue()
)
embed.add_field(name="Field", value="Value")
await channel.send(embed=embed)

Using the Bot

Configuration

Set environment variable:

export BUB_DISCORD_TOKEN="your_token_here"

Running the Bot

import asyncio
import os
from discord_bot import run_bot

async def main():
    token = os.environ.get("BUB_DISCORD_TOKEN")
    await run_bot(token)

asyncio.run(main())

Common Patterns

Respond to Messages

@bot.event
async def on_message(message):
    if message.author.bot:
        return
    if "hello" in message.content.lower():
        await message.reply("Hello!")

Command with Arguments

@bot.command(name="echo")
async def echo(ctx, *, text: str):
    await ctx.send(text)

Button Interaction

from discord.ui import Button, View

button = Button(label="Click me", style=discord.ButtonStyle.primary)
async def callback(interaction):
    await interaction.response.send_message("Clicked!")

button.callback = callback
view = View()
view.add_item(button)
await ctx.send("Click:", view=view)

Environment

  • BUB_DISCORD_TOKEN: Bot token from Discord Developer Portal

04 同仓库更多 Skills

bubbuild
bubbuild/bub-contrib

tape-dataset-share-review

Export, filter, scan, and review shareable tape datasets produced by `tape-dataset-opendal`. Use when Codex needs to prepare Bub-generated tape data for public sharing, Hugging Face upload, external research handoff, or any review-sensitive export that must run CEL filtering, TruffleHog secret scanning on the staged artifact, and a final conservative LLM audit.

★ 19
bubbuild
bubbuild/bub-contrib

wecom

WeCom channel skill. Return normal replies directly. For proactive sends such as scheduled jobs, use the packaged wecom_send.py script.

★ 19
bubbuild
bubbuild/bub-contrib

slack

Slack skill for proactive outbound Slack communication: posting a message to a channel or thread, editing an existing bot message, or adding an emoji reaction. Use when the bot needs to: (1) post a message somewhere OTHER than the current reply (e.g. a different channel, or a side note in the same thread), (2) edit a previously-sent bot message (e.g. a progress placeholder), or (3) acknowledge a message with a non-verbal emoji reaction. NOTE: normal replies to the current message are posted AUTOMATICALLY by the runtime — just answer as text. Reach for this skill only for proactive / out-of-band sends and message edits.

★ 19
bubbuild
bubbuild/bub-contrib

qq

QQ C2C and group channel skill. Use when Bub is handling a QQ conversation. In the default tool reply mode, reply by calling qq.send (text or media) and stay silent by not calling it. In direct reply mode, return the reply text; output exactly <no_reply/> to stay silent.

★ 19
bubbuild
bubbuild/bub-contrib

feishu

Use this skill to respond to messages from feishu channel.

★ 19
bubbuild
bubbuild/bub-contrib

dingtalk

DingTalk channel skill. When $dingtalk appears in message context, return your response as text and the framework will deliver it. For programmatic sends (e.g. progress updates), use dingtalk_send.

★ 19