MKE0108 commited on
Commit
6db0439
·
1 Parent(s): eaebc4c
Files changed (1) hide show
  1. bot_main.py +13 -3
bot_main.py CHANGED
@@ -183,14 +183,24 @@ async def create_bad_message(topic, n=10):
183
  return result
184
  return "為什麼要演奏春日影?"
185
 
186
- # 使用非同步的 Discord bot command
 
187
  @bot.hybrid_command(name="重力場", description="重力發言")
188
  @app_commands.describe(topic="主題")
189
  async def join(ctx, topic="樂團"):
190
- # 異步等待訊息生成
191
  await ctx.defer()
 
 
192
  messege = await create_bad_message(topic)
193
- await ctx.send(f'## {messege}')
 
 
 
 
 
 
 
194
 
195
 
196
  bot.run(os.getenv('BOT_TOKENS'))
 
183
  return result
184
  return "為什麼要演奏春日影?"
185
 
186
+
187
+
188
  @bot.hybrid_command(name="重力場", description="重力發言")
189
  @app_commands.describe(topic="主題")
190
  async def join(ctx, topic="樂團"):
191
+ # 延遲回應,防止互動過期
192
  await ctx.defer()
193
+
194
+ # 生成訊息
195
  messege = await create_bad_message(topic)
196
+
197
+ # 檢查頻道名稱是否是 "一般" 或 "general"
198
+ if ctx.channel.name in ["一般", "general"]:
199
+ # 如果頻道是 "一般" 或 "general",延遲 1000 秒刪除訊息
200
+ await ctx.send(f'## {messege}', delete_after=1000)
201
+ else:
202
+ await ctx.send(f'## {messege}')
203
+
204
 
205
 
206
  bot.run(os.getenv('BOT_TOKENS'))