async def callback(self, inter: disnake.ModalInteraction):
chatid = inter.text_values['chatid']
name = inter.text_values['name']
categoryid : int = inter.text_values['categoryid']
bot.location_name = name
thread = await inter.guild.fetch_channel(chatid)
category = await bot.fetch_channel(categoryid)
voice_channel = await category.create_voice_channel(name=name)
existing_channel = disnake.utils.get(category.voice_channels, name=name)
if category is None:
embed = disnake.Embed(title='**Категория не найдена**', color=0xc73939)
await inter.response.send_message(embed=embed, ephemeral=True)
if voice_channel is None:
voice_channel = await category.create_voice_channel(name=name)
if existing_channel:
embed = disnake.Embed(title='**Голосовой канал с таким названием уже существует**', color=0xc73939)
await inter.response.send_message(embed=embed, ephemeral=True)
return
pass
bot.category = category
bot.voice = voice_channel
embed = disnake.Embed(title='Успешно!', color=0x789789)
await inter.response.send_message(embed=embed, ephemeral=True)
msg = await thread.send(view=Btns())
db.insert_table(msg.id, name, voice_channel.id)
```
#Why 'return' doesn't work???
1 messages · Page 1 of 1 (latest)
return doesn't working, instead of just sending embed, bot sends embed and creates voice_channel
Becuase existing_channel is probably not truthy?
And I'm not sure what's going on with that random pass in the middle.
interesting "bot vars"
Kinda surprised you're not just getting an error.
categoryid : int = inter.text_values['categoryid'] that's a string, so
category = await bot.fetch_channel(categoryid) so this should give you NotFound exception
category id is ID, only numbers, why it must be string?
No errors
Because it's coming from a modal payload.
: int
?
yeah, whatever
if existing_channel:
embed = disnake.Embed(title='**Голосовой канал с таким названием уже существует**', color=0xc73939)
await inter.response.send_message(embed=embed, ephemeral=True)
return
if category is None:
embed = disnake.Embed(title='**Категория не найдена**', color=0xc73939)
await inter.response.send_message(embed=embed, ephemeral=True)
if voice_channel is None:
voice_channel = await category.create_voice_channel(name=name)
reeturn
why bot create voice channel instead of just sending an error message embed