I'm trying to make a votekick bot for discord that will mute the person from voice. However, there is a Command not found error when I run the Yes and No functions. So far, this is what I have:
@bot.command(name='votekick')
@commands.has_role('Player')
async def votekick(ctx, user: discord.Member):
await ctx.send('A votekick against {} has started. Type .yes to vote to mute this person and .no if you don\'t want this person to be muted.'.format(user.name))
server = ctx.message.guild
role_id = 805035493573394452
for member in server.members:
if role_id in member.roles:
member.add_roles(get(member.guild.roles, name='able'))
arole = get(member.guild.roles, name='able')
yes=0
no=0
while len(arole.members) > 0:
@bot.command(name='yes')
@commands.has_role('able')
async def voteyes(ctx):
author=ctx.message.author
message=ctx.message
await bot.delete_message(message)
await ctx.send('Player {} has voted.'.format(author.display_name))
author.remove_roles(get(author.guild.roles, name='able'))
global yes
yes=yes+1
@bot.command(name='no')
@commands.has_role('able')
async def voteno(ctx):
author = ctx.message.author
message = ctx.message
await bot.delete_message(message)
await ctx.send('Player {} has voted.'.format(author.display_name))
author.remove_roles(get(author.guild.roles, name='able'))
global no
no = no+1
if yes > no:
return None
else:
await user.edit(mute=True)
Can anyone tell me what is wrong? Thanks in advance!
votenoorvoteyes(which won't be nested) will know whom to kick. This does unfortunately get a bit complicated, especially if multiple people get nominated to be kicked at the same time.