这不允许机器人响应 webhooks,但它也不允许机器人响应其他机器人
import discord
from discord.ext import commands
from discord import utils
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author.bot:
return
else:
msg = message.content
webhooks = await message.channel.webhooks()
webhook = utils.get(webhooks, name = "Backups")
if webhook is None:
webhook = await message.channel.create_webhook(name = "Backups")
await webhook.send(msg, username = message.author.name, avatar_url = message.author.avatar_url)
client.run('TOKEN')
答案 0 :(得分:0)
您可以检查 Message.webhook_id
。如果不是 None
,则消息由网络钩子发送
if message.webhook_id is not None:
return
...