空房間移除下限修改至0
This commit is contained in:
1 parent
d0ed93162f
commit
964d16303f
3 files changed
+6
-6
No files matched your search
+2
-2
@@ -50,14 +50,14 @@ class Settings(commands.GroupCog, group_name="設定", group_description="機器
|
||||
@app_commands.describe(
|
||||
觸發頻道="進入這個語音頻道就會建立包廂",
|
||||
包廂名稱="新包廂的名稱",
|
||||
空房秒數="包廂沒人超過幾秒就刪除",
|
||||
空房秒數="包廂沒人超過幾秒就刪除,0 為立即刪除",
|
||||
)
|
||||
async def rooms(
|
||||
self,
|
||||
interaction: discord.Interaction,
|
||||
觸發頻道: Optional[discord.VoiceChannel] = None,
|
||||
包廂名稱: Optional[app_commands.Range[str, 1, 100]] = None,
|
||||
空房秒數: Optional[app_commands.Range[int, 5, 86400]] = None,
|
||||
空房秒數: Optional[app_commands.Range[int, 0, 86400]] = None,
|
||||
):
|
||||
await apply(
|
||||
interaction,
|
||||
|
||||
+2
-2
@@ -92,13 +92,13 @@ class VoiceRooms(commands.Cog):
|
||||
|
||||
with db.conn:
|
||||
db.add_room(room.id)
|
||||
# 先開始倒數,如果來不及移動(成員已離開)包廂也會被清掉;移動成功時會取消
|
||||
self.refresh_timer(room)
|
||||
|
||||
# 移動完才能開始倒數,否則空房秒數為 0 時包廂會在移動途中被刪掉
|
||||
try:
|
||||
await member.move_to(room, reason="移動到私人包廂")
|
||||
except discord.HTTPException:
|
||||
log.warning("無法把 %s 移動到包廂 %s", member, room.id)
|
||||
self.refresh_timer(room) # 成員已離開,空包廂一樣要清掉
|
||||
|
||||
def refresh_timer(self, channel: discord.VoiceChannel):
|
||||
"""有人就取消計時,沒人就開始計時(只剩其他機器人也算沒人)"""
|
||||
|
||||
Reference in new issue
Block a user