@commands.command()
async def mute(self, ctx, member : discord.Member = None):
try:
if isinstance(member, discord.Member):
await member.edit(mute=True)
elif member is None: #setting the command to mute selected member
member=get(ctx.guild.members, id=Charles_id)
await member.edit(mute=True)
except discord.HTTPException:
await ctx.channel.send(f"User {member.mention} isn't connected to voice channel")
except discord.ext.commands.errors.MemberNotFound("@everyone"):
vc = ctx.author.voice.channel
for user in vc.members:
await user.edit(mute=True)
So I'm trying to make a command that mutes the mentioned player. By default its supposed to mute our friend, Charles. The only problem was with default role (@Everyone). I struggled a lot but finally I managed to come up with a working idea. Sadly it doesn't really work. The plan was to try getting member and if member is @everyone it would run an error that would trigger except and would end up doing its' stuff. I'm pretty new to programming so I hope to get a useful lesson, Cheers!
Traceback is below:
Ignoring exception in command ryj:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 851, in invoke
await self.prepare(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 786, in prepare
await self._parse_arguments(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 552, in transform
return await self.do_conversion(ctx, converter, argument, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 505, in do_conversion
return await self._actual_conversion(ctx, converter, argument, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 451, in _actual_conversion
ret = await instance.convert(ctx, argument)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 191, in convert
raise MemberNotFound(argument)
discord.ext.commands.errors.MemberNotFound: Member "@everyone" not found.