forked from nohararc/discord_voiceroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
52 lines (37 loc) · 1.78 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import discord
from typing import List
from Item import Item
class TextChannelButton(discord.ui.Button["SelectTextChannel"]):
def __init__(self, label: str, text_channel: discord.TextChannel):
super().__init__(style=discord.ButtonStyle.secondary, label=None)
self.text_channel = text_channel
self.label = label
async def callback(self, interaction: discord.Interaction):
content = f"{self.label}を読み上げます"
for child in self.view.children:
child.disabled = True
self.view.stop()
Item.text_channel = self.text_channel
await interaction.response.edit_message(content=content, view=self.view)
class SelectTextChannel(discord.ui.View):
def __init__(self, text_channels: List[discord.TextChannel]):
super().__init__()
for tc in text_channels:
self.add_item(TextChannelButton(label=tc.name, text_channel=tc))
class VoiceChannelButton(discord.ui.Button["SelectVoiceChannel"]):
def __init__(self, label: str, voice_channel: discord.VoiceChannel):
super().__init__(style=discord.ButtonStyle.secondary, label=None)
self.voice_channel = voice_channel
self.label = label
async def callback(self, interaction: discord.Interaction):
content = f"{self.label}で読み上げます"
for child in self.view.children:
child.disabled = True
self.view.stop()
Item.voice_channel = self.voice_channel
await interaction.response.edit_message(content=content, view=self.view)
class SelectVoiceChannel(discord.ui.View):
def __init__(self, voice_channels: List[discord.VoiceChannel]):
super().__init__()
for vc in voice_channels:
self.add_item(VoiceChannelButton(label=vc.name, voice_channel=vc))