超时消息作者使用Discord.py



我正在使用discord.py制作一个不和命令,用户可以调用该命令,并且作者本身有50%的机会超时。这是我到目前为止所写的,我不知道如何调用超时部分

async def zeus(ctx):
val = 1
boom = random.randint(1,2)
if val == boom:
await #timesout the author/the caller of command for 10 minutes
else:
pass

编辑:我不知道如何使用会员。time_out_until为作者自己。

这应该可以工作(我只在py-cord中测试过,但它应该可以在discord.py中工作)

import datetime
import discord 
from discord.ext import commands
import random
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix = "!", intents=intents)
@bot.command()
async def zeus(ctx):
boom = random.randint(0, 1) == 0
if boom:
await ctx.message.author.timeout_for(datetime.timedelta(seconds=10))
bot.run("TOKEN HERE")

最新更新