import discord,os
from discord import ui,app_commands
guild_id = 858984157929144321
class aclient(discord.Client):
def __init__(self):
super().__init__(intents = discord.Intents.default())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild = discord.Object(id=guild_id))
self.synced = True
print(f"We have logged in as {self.user}.")
class MyModal(ui.Modal,title="cool"):
answer = ui.TextInput(label="建議",style=discord.TextStyle.short,placeholder="我發現``太爛了...")
async def on_submit(self, interaction: discord.Interaction):
await interaction.response.send_message('哞!傳送成功!')
user = await client.fetch_user("823122263552425984")
await user.send(self.answer)
client = aclient()
tree = app_commands.CommandTree(client)
@tree.command(guild = discord.Object(id=guild_id), name = 'cow suggest', description='告訴我你想到的新功能')
async def slash2(interaction: discord.Interaction):
await interaction.response.send_modal(MyModal())
client.run(os.environ['token'])