@@ -28,6 +28,7 @@ class AdminOption(str, Enum):
28
28
"""管理コマンドのオプション"""
29
29
SERVERS = "servers"
30
30
DEBUG = "debug"
31
+ VOICE = "voice"
31
32
32
33
class PaginationView (View ):
33
34
"""ページネーション用のカスタムビュー"""
@@ -255,6 +256,47 @@ async def create_request_embeds(self) -> List[discord.Embed]:
255
256
256
257
return embeds
257
258
259
+ async def create_voice_channel_embeds (self ) -> List [discord .Embed ]:
260
+ """現在ボットが参加しているVC一覧を作成"""
261
+ embeds = []
262
+ current_embed = discord .Embed (
263
+ title = "ボットが参加しているVC一覧" ,
264
+ color = EMBED_COLORS ["info" ]
265
+ )
266
+
267
+ voice_states = [
268
+ (guild .name , channel .name , len (channel .members ))
269
+ for guild in self .bot .guilds
270
+ for channel in guild .voice_channels
271
+ if channel .guild .voice_client and channel .guild .voice_client .channel == channel
272
+ ]
273
+
274
+ if not voice_states :
275
+ current_embed .description = "現在ボットはどのVCにも参加していません。"
276
+ embeds .append (current_embed )
277
+ return embeds
278
+
279
+ for i , (guild_name , channel_name , member_count ) in enumerate (voice_states , 1 ):
280
+ value = (
281
+ f"サーバー: { guild_name } \n "
282
+ f"チャンネル: { channel_name } \n "
283
+ f"メンバー数: { member_count } "
284
+ )
285
+ current_embed .add_field (
286
+ name = f"VC { i } " ,
287
+ value = value ,
288
+ inline = False
289
+ )
290
+
291
+ if i % SERVERS_PER_PAGE == 0 or i == len (voice_states ):
292
+ embeds .append (current_embed )
293
+ current_embed = discord .Embed (
294
+ title = "ボットが参加しているVC一覧 (続き)" ,
295
+ color = EMBED_COLORS ["info" ]
296
+ )
297
+
298
+ return embeds
299
+
258
300
async def generate_premium_token (self , user_id : int ) -> str :
259
301
"""指定したユーザーにプレミアムトークンを発行し、DMを送信"""
260
302
user_data = self .db .get_user (user_id )
@@ -313,6 +355,15 @@ async def botadmin_command(
313
355
ephemeral = True
314
356
)
315
357
358
+ elif option == AdminOption .VOICE :
359
+ embeds = await self .create_voice_channel_embeds ()
360
+ view = PaginationView (embeds )
361
+ await interaction .response .send_message (
362
+ embed = embeds [0 ],
363
+ view = view ,
364
+ ephemeral = True
365
+ )
366
+
316
367
elif option .startswith ("premium:" ):
317
368
if not self .is_admin (interaction .user .id ):
318
369
embed = discord .Embed (
0 commit comments