Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道要让发送 dm 的用户,这个想法是阻止人们在 dm 中使用机器人,然后在 #bot-lab 中对他们执行 ping 操作,以便他们可以在那里使用它
我还没有尝试过任何东西,但如果有人告诉我该怎么做,那就太好了
谢谢你
在 discord.py 中,您可以使用isinstance(ctx.channel, discord.channel.DMChannel)来检查消息是否为 DM。
isinstance(ctx.channel, discord.channel.DMChannel)
@client.command() async def check(ctx, arg): if isinstance(ctx.channel, discord.channel.DMChannel): await ctx.send(arg)