import sys
sys.dont_write_bytecode = True
import nextcord, sqlite3, datetime, asyncio
from nextcord import Embed, Color, SlashOption
from nextcord import Interaction as inter
from nextcord.ext import commands
from config import *
intents = nextcord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
sleep = asyncio.sleep
class Join(nextcord.ui.View):
def __init__(self, msg: nextcord.PartialInteractionMessage, members: str, emb: nextcord.Embed, btm: str, channel: nextcord.TextChannel):
super().__init__(timeout=None)
self.value = None
self.msg = msg
self.members = members
self.total = 1
self.emb = emb
self.btm = btm
self.channel = channel
@nextcord.ui.button(label='Присоединиться', style=nextcord.ButtonStyle.grey)
async def callback(self, button: nextcord.ui.Button, i: inter):
if self.total == 5:
await i.send("Максимальное количество игроков", ephemeral=True)
self.emb.title = "Поиск завершён | " + self.emb.title.split(" | ")[1]
await self.msg.edit(embed=self.emb)
return
if i.user.mention in self.emb.description:
await i.send("Вы уже состоите в наборе", ephemeral=True)
return
self.members = self.members + f"{i.user.mention}\n"
self.total += 1
self.emb = Embed(title=self.emb.title, description=self.members + self.btm)
await self.msg.edit(embed=self.emb)
await self.channel.set_permissions(i.user, read_messages=True)
@bot.slash_command(name='new', guild_ids=[server_id])
async def new(i: inter, имя: str, тип = SlashOption(choices={typ: typ for typ in types})):
category = nextcord.utils.get(i.guild.categories, id=category)
if i.channel.id != channel_id: await i.send(f"В этом канале нельзя создавать наборы. Используйте канал ", ephemeral=True); return
bottom: str = f"_ _\n**Тип:**\n{тип}"
members: str = f'{i.user.mention}\n'
embed = Embed(title='В поиске ... | ' + имя, description=i.user.mention + bottom)
new_channel = await i.guild.create_text_channel(name=имя, category=category)
await new_channel.set_permissions(i.user, read_messages=True)
m = await i.send('', embed=embed)
await m.edit(view=Join(m, members, embed, bottom, new_channel))
bot.run(bot_token)
По какой-то причине он работает, когда я использую его с другом, но когда я использую его на других участниках сервера, он всегда говорит "Вы уже состоите в наборе".
p>
Я пробовал задать gpt в чате, выполнить несколько тестов и записать информацию, но ничего не помогло
Я ожидал, что бот Discord сработает
У меня есть бот Discord, который отправляет пользователей в частный текстовый канал для общения. Вот код бота на Python: [code]import sys sys.dont_write_bytecode = True
import nextcord, sqlite3, datetime, asyncio from nextcord import Embed, Color, SlashOption from nextcord import Interaction as inter from nextcord.ext import commands from config import *
bot.run(bot_token) [/code] По какой-то причине он работает, когда я использую его с другом, но когда я использую его на других участниках сервера, он всегда говорит "Вы уже состоите в наборе". p> Я пробовал задать gpt в чате, выполнить несколько тестов и записать информацию, но ничего не помогло Я ожидал, что бот Discord сработает