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

17 statements  

1""" 

2kick.py 

3 

4includes kick 

5""" 

6 

7from client import client 

8from database import get 

9from error import AuthorisationError, ArgumentRequiredError 

10 

11 

12async def kick(message, *args): 

13 """ 

14 kick 

15 

16 kicks person from guild given id 

17 """ 

18 

19 # get admins from database 

20 admins = get("admins") 

21 

22 if any([ 

23 message.channel.permissions_for(message.author).administrator, 

24 str(message.author.id) in admins, 

25 ]): 

26 

27 if args: 

28 

29 try: 

30 

31 client.get_user(int(args[0])).id 

32 

33 except AttributeError: 

34 

35 return 'Unknown user' 

36 

37 except ValueError: 

38 

39 return 'User ID not found' 

40 

41 await message.guild.kick(client.get_user(int(args[0]))) 

42 

43 return 'User <@' + str(args[0]) + '> has been kicked' 

44 

45 raise ArgumentRequiredError('User ID') 

46 

47 raise AuthorisationError