discord.py - 当在类别下创建频道时,我如何让我的机器人说些什么?
问题描述
我正在尝试让我的 Discord 机器人说些什么,并在创建频道等时等待消息,但是我不知道该怎么做,这是我现在正在处理的代码:
import discord, asyncio
discord_token = open('token.txt').read()
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.lower().startswith('test'):
await message.channel.send('testing, sending to channel works!')
@client.event
async def on_ready():
print('Successfully connected to', client.user)
client.run(discord_token)
解决方案
@client.event
async def on_guild_channel_create(channel):
if channel.category: #if the channel created is in a category
#send something
await channel.send("Something")
推荐阅读
- c - 相同值的指针比较不相等
- html - how to make two columns with different background and left right spacing in bootstrap
- mapbox-gl-js - Where can I view older Mapbox GL JS API documentation?
- php - PHP Variable not acting as a reference
- python - how to make an xml http post request from the information provided by the google chrome inspector
- laravel - Laravel 5.4:观察者事件不适用于 PHPUnit
- r - 在 R 中的参数值范围内运行 2 个参数的函数
- android - Split a Relative Layout with wrap_content
- javascript - 如何创建一个 javascript 脚本来调整 CSS 中表单的宽度?
- security - Is there value for including the [ValidateAntiForgeryToken] attribute on the Login action?