37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from typing import Optional
|
|
|
|
import discord
|
|
from discord import app_commands
|
|
from discord.ext import commands
|
|
|
|
import db
|
|
|
|
|
|
class Settings(commands.Cog):
|
|
@app_commands.command(name="設定", description="設定簽到頻道與表符(管理員)")
|
|
@app_commands.describe(
|
|
簽到表符="簽到用的表符,如 🪙 或自訂表符",
|
|
簽到頻道="只偵測這個頻道,不填則偵測所有頻道",
|
|
)
|
|
@app_commands.guild_only()
|
|
@app_commands.default_permissions(administrator=True)
|
|
async def settings(
|
|
self,
|
|
interaction: discord.Interaction,
|
|
簽到表符: str,
|
|
簽到頻道: Optional[discord.TextChannel] = None,
|
|
):
|
|
emoji = 簽到表符.strip()
|
|
with db.conn:
|
|
db.set_server(interaction.guild.id, 簽到頻道.id if 簽到頻道 else None, emoji)
|
|
|
|
channel_text = 簽到頻道.mention if 簽到頻道 else "所有頻道"
|
|
await interaction.response.send_message(
|
|
f"已更新簽到設定:\n頻道:{channel_text}\n表符:{emoji}",
|
|
ephemeral=True,
|
|
)
|
|
|
|
|
|
async def setup(bot: commands.Bot):
|
|
await bot.add_cog(Settings())
|