Coverage for cmds/kick.py: 24%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2kick.py
4includes kick
5"""
7from client import client
8from database import get
9from error import AuthorisationError, ArgumentRequiredError
12async def kick(message, *args):
13 """
14 kick
16 kicks person from guild given id
17 """
19 # get admins from database
20 admins = get("admins")
22 if any([
23 message.channel.permissions_for(message.author).administrator,
24 str(message.author.id) in admins,
25 ]):
27 if args:
29 try:
31 client.get_user(int(args[0])).id
33 except AttributeError:
35 return 'Unknown user'
37 except ValueError:
39 return 'User ID not found'
41 await message.guild.kick(client.get_user(int(args[0])))
43 return 'User <@' + str(args[0]) + '> has been kicked'
45 raise ArgumentRequiredError('User ID')
47 raise AuthorisationError