Spaces:
Paused
Paused
add
Browse files- bot_main.py +8 -0
bot_main.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
| 3 |
from discord import app_commands
|
|
|
|
| 4 |
import os
|
| 5 |
try:
|
| 6 |
from keys import init
|
|
@@ -62,6 +63,13 @@ def get_pick_embed(player):
|
|
| 62 |
@bot.hybrid_command(name="選路",description="會從<<指定語音頻道>>和<<指定其他玩家名稱>>中選路線")
|
| 63 |
@app_commands.describe(channel_name="語音頻道名稱",other_user="其他玩家名稱")
|
| 64 |
async def pick(ctx, channel_name:str="",other_user:str=""):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# 搜尋指定名稱的語音頻道
|
| 66 |
voice_channel = discord.utils.get(ctx.guild.voice_channels, name=channel_name)
|
| 67 |
try:
|
|
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
| 3 |
from discord import app_commands
|
| 4 |
+
import difflib
|
| 5 |
import os
|
| 6 |
try:
|
| 7 |
from keys import init
|
|
|
|
| 63 |
@bot.hybrid_command(name="選路",description="會從<<指定語音頻道>>和<<指定其他玩家名稱>>中選路線")
|
| 64 |
@app_commands.describe(channel_name="語音頻道名稱",other_user="其他玩家名稱")
|
| 65 |
async def pick(ctx, channel_name:str="",other_user:str=""):
|
| 66 |
+
#尋找最接近的語音頻道
|
| 67 |
+
voice_channel_list = ctx.guild.voice_channels
|
| 68 |
+
text_to_match = channel_name
|
| 69 |
+
closest_match = difflib.get_close_matches(text_to_match, voice_channel_list, n=1)
|
| 70 |
+
closest_match = closest_match[0] if closest_match else None
|
| 71 |
+
channel_name = closest_match
|
| 72 |
+
|
| 73 |
# 搜尋指定名稱的語音頻道
|
| 74 |
voice_channel = discord.utils.get(ctx.guild.voice_channels, name=channel_name)
|
| 75 |
try:
|