Update app.py
Browse files
app.py
CHANGED
|
@@ -151,6 +151,39 @@ async def wismer_commands(interaction: discord.Interaction):
|
|
| 151 |
|
| 152 |
ADMIN_LOG_CHANNEL_ID = 1468391869686878455
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
@client.tree.command(name="uploadmat", description="Upload a study link")
|
| 155 |
@app_commands.choices(category=[app_commands.Choice(name=c, value=c) for c in CATEGORIES])
|
| 156 |
async def uploadmat(interaction: discord.Interaction, category: str, title: str, url: str):
|
|
@@ -222,6 +255,7 @@ async def unappmats(interaction: discord.Interaction, category: str):
|
|
| 222 |
embed = discord.Embed(title=f"⏳ {category} Pending", description=list_text, color=discord.Color.orange())
|
| 223 |
await interaction.followup.send(embed=embed)
|
| 224 |
|
|
|
|
| 225 |
# --- 6. 启动逻辑 ---
|
| 226 |
async def start_bot():
|
| 227 |
token = os.getenv('DISCORD_TOKEN')
|
|
|
|
| 151 |
|
| 152 |
ADMIN_LOG_CHANNEL_ID = 1468391869686878455
|
| 153 |
|
| 154 |
+
# 允许调用指令的用户名列表(或者 User ID)
|
| 155 |
+
ALLOWED_USERS = ["tonydong365"]
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
# 另一个独立的函数:负责最后的匿名发送
|
| 159 |
+
async def send_anonymous_message(channel, content):
|
| 160 |
+
await channel.send(content)
|
| 161 |
+
|
| 162 |
+
@bot.tree.command(name="say", description="idk what is this")
|
| 163 |
+
@app_commands.describe(content="idk")
|
| 164 |
+
async def secret(interaction: discord.Interaction, content: str):
|
| 165 |
+
# 1. 读取并核对用户名
|
| 166 |
+
current_user = interaction.user.name
|
| 167 |
+
|
| 168 |
+
# 检查当前用户是否在允许列表中
|
| 169 |
+
if current_user not in ALLOWED_USERS:
|
| 170 |
+
# 如果不是特定用户,直接回复一个仅自己可见的消息并结束
|
| 171 |
+
# 或者干脆不给任何反馈直接 return
|
| 172 |
+
await interaction.response.send_message("This is nothing.", ephemeral=True)
|
| 173 |
+
return
|
| 174 |
+
|
| 175 |
+
# 2. 如果是特定用户,先发送一个极其简短的“瞬时响应”来完成交互
|
| 176 |
+
# 这样频道里其他人完全看不见
|
| 177 |
+
await interaction.response.send_message("指令已确认...", ephemeral=True)
|
| 178 |
+
|
| 179 |
+
# 3. 立即清理掉这个“瞬时响应”,不留痕迹
|
| 180 |
+
await interaction.delete_original_response()
|
| 181 |
+
|
| 182 |
+
# 4. 调用另一个函数进行“无关联”发送
|
| 183 |
+
await send_anonymous_message(interaction.channel, content)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
|
| 187 |
@client.tree.command(name="uploadmat", description="Upload a study link")
|
| 188 |
@app_commands.choices(category=[app_commands.Choice(name=c, value=c) for c in CATEGORIES])
|
| 189 |
async def uploadmat(interaction: discord.Interaction, category: str, title: str, url: str):
|
|
|
|
| 255 |
embed = discord.Embed(title=f"⏳ {category} Pending", description=list_text, color=discord.Color.orange())
|
| 256 |
await interaction.followup.send(embed=embed)
|
| 257 |
|
| 258 |
+
|
| 259 |
# --- 6. 启动逻辑 ---
|
| 260 |
async def start_bot():
|
| 261 |
token = os.getenv('DISCORD_TOKEN')
|