У меня есть код, где при каждом муте пользователя - меняться сообщение. А мне нужно что бы только при заходе/выходе менялся. Как сделать проверку на мут?
@commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
if after.channel and not before.channel:
channels = after.channel
elif before.channel and not after.channel:
channels = before.channel
elif before.channel and after.channel:
channels = before.channel
channels2 = after.channel
finds1 = await self.privates.find_one({"channel_id": channels2.id})
finds = await self.privates.find_one({"channel_id": channels.id})
if finds:
if 'msg_id' in finds.keys():
channel = self.bot.get_channel(text_channel)
msg = await channel.fetch_message(finds['msg_id'])
if msg:
voice = channels
limit = len(voice.members)
limit_bd = voice.user_limit
if limit_bd > limit:
emb = discord.Embed(
description=f'<:s:974805554058899477>{finds["text"]}\n\n',
timestamp=datetime.datetime.utcnow()
)
emb.set_thumbnail(url=random.choice(image))
author = member.guild.get_member(finds['member_id'])
url_s = f'https://discord.gg/{finds["inv_code"]}'
emb.set_author(
icon_url=author.avatar_url, name=f'{voice.name}', url=url_s)
for members in voice.members:
emb.description += f'<:f:959016408304459806> {members.mention}\n'
limit_none = limit_bd - limit
for i in range(limit_none):
emb.description += f'<:q:960469200399380530> -\n'
emb.set_footer(
text=f'В поиске команды. +{limit_none}')
butns = [
create_button(
ButtonStyle.URL, label='Присоединится!', url=f'{url_s}')
]
row = create_actionrow(*butns)
await msg.edit(embed=emb, components=[row])
else:
emb = discord.Embed(
description=f'<:s:974805554058899477>{finds["text"]}\n\n',
timestamp=datetime.datetime.utcnow()
)
emb.set_thumbnail(url=random.choice(image))
author = member.guild.get_member(finds['member_id'])
emb.set_author(
icon_url=author.avatar_url, name=f'{voice.name}')
for members in voice.members:
emb.description += f'<:f:959016408304459806> {members.mention}\n'
emb.set_footer(
text=f'Канал заполнен <:a:974805978388267048>')
await msg.edit(embed=emb, components=[])
(некоторые моменты кода можно сделать и проще, но это уже отдельный момент)