1 回答
TA贡献1858条经验 获得超8个赞
你不需要不和谐的客户端。如果您已经在使用discord.ext.commands,则可以按如下方式操作。
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=".", intents=intents)
@bot.event
async def on_ready():
print(f"Bot is ready")
await bot.change_presence(status=discord.Status.online, activity=discord.Game(name="example"))
@bot.event
async def on_message(message):
forbidden_word = "word"
if forbidden_word in message.content:
await message.delete()
@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member):
await member.kick()
await ctx.send(f"Member {member} has been kicked")
bot.run("token")
on_message 在消息创建和发送时被调用。必须启用discord.Intents.messages,或者使用intents = discord.Intents.all()来启用所有Intents
添加回答
举报