【发布时间】:2021-08-07 00:37:33
【问题描述】:
所以,我想做的是使用 discord.py 阻止特定角色在不和谐频道中发言。
这是我目前所拥有的。
import discord
import os
from keep_alive import keep_alive
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):
countingBotGuildSave = ['test']
if any(word in message.content for word in countingBotGuildSave):
await message.channel.set_permissions(discord.utils.get(message.guild.members, name='Foo'), send_messages=False)
await message.channel.send('**An admin/moderator has locked this channel. Please wait for an admin to unlock this channel with `+unlock`.**')
print(f'{message.author} locked channel {message.channel}')
keep_alive()
client.run(os.getenv('TOKEN'))
这在我运行机器人时不会导致任何错误,但是当我不和谐地说test 时,它说:目标参数必须是成员或角色。我不明白,因为我做了一个名为 Foo 的角色。
你能帮忙吗?
Tysm。
【问题讨论】:
标签: discord.py