提醒命令问题
Reminder Command issue
我的提醒命令有问题。当提醒命令为运行ning时,它可以正常工作:它会在你提供的秒数内提醒你。但是当它 运行 提醒时,它不会 运行 任何其他命令,直到它有 DM 来提醒你。
这是代码。我不太擅长解释;你可以问问题。
@client.command()
async def remindersec(ctx,seconds=None):
try:
embed = discord.Embed(title = f"I will remind you in {seconds} seconds",
description = f"You'll be DMed as a reminder.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
timer = int(seconds)
while timer >= 0:
import time
time.sleep(1)
timer -= 1
await ctx.author.send("Reminder!")
except ValueError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
except TypeError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
不要使用时间模块。使用异步。所以就像:-
import asyncio
timer = int(seconds)
while timer >= 0:
await asyncio.sleep(1)
timer -= 1
await ctx.author.send("Reminder!")
except ValueError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)
我的提醒命令有问题。当提醒命令为运行ning时,它可以正常工作:它会在你提供的秒数内提醒你。但是当它 运行 提醒时,它不会 运行 任何其他命令,直到它有 DM 来提醒你。
这是代码。我不太擅长解释;你可以问问题。
@client.command()
async def remindersec(ctx,seconds=None):
try:
embed = discord.Embed(title = f"I will remind you in {seconds} seconds",
description = f"You'll be DMed as a reminder.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
timer = int(seconds)
while timer >= 0:
import time
time.sleep(1)
timer -= 1
await ctx.author.send("Reminder!")
except ValueError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
except TypeError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
不要使用时间模块。使用异步。所以就像:-
import asyncio
timer = int(seconds)
while timer >= 0:
await asyncio.sleep(1)
timer -= 1
await ctx.author.send("Reminder!")
except ValueError:
embed = discord.Embed(title = "Error!",
description = f"Please type a valid number.",
color = 0xf461ff)