mirror of
https://code.lenaisten.de/Lenaisten/lenaverse-bot.git
synced 2024-11-22 15:03:01 +00:00
"lsstuff" app command
This commit is contained in:
parent
20da5bd078
commit
8a328270cd
2 changed files with 18 additions and 2 deletions
|
@ -2,7 +2,7 @@ import logging
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from .commands import post
|
from .commands import lsstuff, post
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class LenaverseBot(discord.Client):
|
||||||
|
|
||||||
self.tree = discord.app_commands.CommandTree(self)
|
self.tree = discord.app_commands.CommandTree(self)
|
||||||
self.tree.add_command(post)
|
self.tree.add_command(post)
|
||||||
|
self.tree.add_command(lsstuff)
|
||||||
|
|
||||||
async def setup_hook(self):
|
async def setup_hook(self):
|
||||||
await self.tree.sync()
|
await self.tree.sync()
|
||||||
|
|
|
@ -37,9 +37,24 @@ class PostModal(ui.Modal, title="foobar2000"):
|
||||||
await view.wait()
|
await view.wait()
|
||||||
|
|
||||||
if view.value:
|
if view.value:
|
||||||
await interaction.user.send(f"Confirmed '{self.content.value}'")
|
await interaction.user.send(self.content.value)
|
||||||
|
|
||||||
|
|
||||||
@discord.app_commands.command()
|
@discord.app_commands.command()
|
||||||
async def post(interaction: discord.Interaction):
|
async def post(interaction: discord.Interaction):
|
||||||
await interaction.response.send_modal(PostModal())
|
await interaction.response.send_modal(PostModal())
|
||||||
|
|
||||||
|
|
||||||
|
@discord.app_commands.command()
|
||||||
|
async def lsstuff(interaction: discord.Interaction):
|
||||||
|
msg = ""
|
||||||
|
for guild in interaction.client.guilds:
|
||||||
|
msg += f"\n- {guild.name}"
|
||||||
|
for channel in guild.channels:
|
||||||
|
msg += f"\n - {channel.name}"
|
||||||
|
|
||||||
|
if isinstance(channel, discord.ForumChannel | discord.TextChannel):
|
||||||
|
for thread in channel.threads:
|
||||||
|
msg += f"\n - {thread.name}"
|
||||||
|
|
||||||
|
await interaction.response.send_message(msg, ephemeral=True)
|
||||||
|
|
Loading…
Reference in a new issue