空房間移除下限修改至0
This commit is contained in:
1 parent
d0ed93162f
commit
964d16303f
3 files changed
+6
-6
No files matched your search
@@ -8,7 +8,7 @@ Discord 伺服器助手,提供私人語音包廂和每日簽到。設定和簽
|
|||||||
|
|
||||||
1. 成員進入觸發語音頻道後,機器人會在同一個類別建立新包廂,並把成員移進去。
|
1. 成員進入觸發語音頻道後,機器人會在同一個類別建立新包廂,並把成員移進去。
|
||||||
2. 建立包廂的人可以修改包廂名稱、人數上限和頻道狀態。這個人離開後,權限不會轉移給其他人。
|
2. 建立包廂的人可以修改包廂名稱、人數上限和頻道狀態。這個人離開後,權限不會轉移給其他人。
|
||||||
3. 包廂沒人超過設定的秒數(預設 30 秒)就會刪除。只剩其他機器人也算沒人,倒數期間有人回來就會取消刪除。
|
3. 包廂沒人超過設定的秒數(預設 30 秒)就會刪除,設成 0 則是一沒人就立即刪除。只剩其他機器人也算沒人,倒數期間有人回來就會取消刪除。
|
||||||
|
|
||||||
機器人重啟後會檢查既有包廂,空的一樣會刪除。
|
機器人重啟後會檢查既有包廂,空的一樣會刪除。
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ Discord 伺服器助手,提供私人語音包廂和每日簽到。設定和簽
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 觸發頻道 | 未設定 | 語音頻道 |
|
| 觸發頻道 | 未設定 | 語音頻道 |
|
||||||
| 包廂名稱 | `🥂 °·˚|私人包廂` | 1~100 字 |
|
| 包廂名稱 | `🥂 °·˚|私人包廂` | 1~100 字 |
|
||||||
| 空房秒數 | `30` | 5~86400 秒 |
|
| 空房秒數 | `30` | 0~86400 秒,0 為立即刪除 |
|
||||||
| 簽到文字 | `月眠🙏` | 可以包含文字、表情和自訂表符 |
|
| 簽到文字 | `月眠🙏` | 可以包含文字、表情和自訂表符 |
|
||||||
| 簽到獎勵 | `1` | 至少 1 |
|
| 簽到獎勵 | `1` | 至少 1 |
|
||||||
| 貨幣名稱 | `願力` | |
|
| 貨幣名稱 | `願力` | |
|
||||||
|
|||||||
+2
-2
@@ -50,14 +50,14 @@ class Settings(commands.GroupCog, group_name="設定", group_description="機器
|
|||||||
@app_commands.describe(
|
@app_commands.describe(
|
||||||
觸發頻道="進入這個語音頻道就會建立包廂",
|
觸發頻道="進入這個語音頻道就會建立包廂",
|
||||||
包廂名稱="新包廂的名稱",
|
包廂名稱="新包廂的名稱",
|
||||||
空房秒數="包廂沒人超過幾秒就刪除",
|
空房秒數="包廂沒人超過幾秒就刪除,0 為立即刪除",
|
||||||
)
|
)
|
||||||
async def rooms(
|
async def rooms(
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
觸發頻道: Optional[discord.VoiceChannel] = None,
|
觸發頻道: Optional[discord.VoiceChannel] = None,
|
||||||
包廂名稱: Optional[app_commands.Range[str, 1, 100]] = 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(
|
await apply(
|
||||||
interaction,
|
interaction,
|
||||||
|
|||||||
+2
-2
@@ -92,13 +92,13 @@ class VoiceRooms(commands.Cog):
|
|||||||
|
|
||||||
with db.conn:
|
with db.conn:
|
||||||
db.add_room(room.id)
|
db.add_room(room.id)
|
||||||
# 先開始倒數,如果來不及移動(成員已離開)包廂也會被清掉;移動成功時會取消
|
|
||||||
self.refresh_timer(room)
|
|
||||||
|
|
||||||
|
# 移動完才能開始倒數,否則空房秒數為 0 時包廂會在移動途中被刪掉
|
||||||
try:
|
try:
|
||||||
await member.move_to(room, reason="移動到私人包廂")
|
await member.move_to(room, reason="移動到私人包廂")
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
log.warning("無法把 %s 移動到包廂 %s", member, room.id)
|
log.warning("無法把 %s 移動到包廂 %s", member, room.id)
|
||||||
|
self.refresh_timer(room) # 成員已離開,空包廂一樣要清掉
|
||||||
|
|
||||||
def refresh_timer(self, channel: discord.VoiceChannel):
|
def refresh_timer(self, channel: discord.VoiceChannel):
|
||||||
"""有人就取消計時,沒人就開始計時(只剩其他機器人也算沒人)"""
|
"""有人就取消計時,沒人就開始計時(只剩其他機器人也算沒人)"""
|
||||||
|
|||||||
Reference in new issue
Block a user