欢迎使用 Discord 开发工具文档页面!这里提供了关于 Discord 开发工具的详细信息和指南。

快速导航

常见问题

以下是一些常见的 Discord 开发问题及其解答:

  • Q: 如何获取 Discord API 的访问令牌? A: 您可以在 Discord 应用设置 中生成一个新的令牌。

  • Q: 如何在 Discord 中发送消息? A: 使用 message.channel.send(content) 方法可以发送消息。

示例代码

import discord

client = discord.Client()

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        await message.channel.send('Hello!')

client.run('YOUR_BOT_TOKEN')

更多示例代码

相关资源

Discord Bot 示例