Advertisement
Guest User

dead inside

a guest
Feb 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. # server -> guild, client.add_roles -> member.add_roles, say and send_message -> ctx.send.
  2. # errors still don't work
  3.  
  4. # Imports
  5. import discord
  6. from discord.utils import get
  7. from discord import Game
  8. import asyncio
  9. from discord.ext.commands import Bot
  10. from discord.ext.commands import *
  11. import discord.ext.commands
  12. import random
  13.  
  14. # Variables
  15. pref = 'k!'
  16. client = Bot(command_prefix=pref)
  17. token = ''
  18. # Main --- Commands
  19. def check(author):
  20. def inner_check(message):
  21. if message.author != author:
  22. return False
  23. try:
  24. int(message.content)
  25. return True
  26. except ValueError:
  27. return False
  28. return inner_check
  29. # Fun
  30. @client.command(name='8ball',
  31. brief='Answers a question',
  32. pass_context=True)
  33. async def eightball(context):
  34. responses = ['That is a resounding no',
  35. 'It is not looking likely',
  36. 'Too hard to tell',
  37. 'It is very possible',
  38. 'Definitely',
  39. 'Try asking later',
  40. 'Your family are disappointed',
  41. 'No comment',
  42. 'Maybe, but Sanji is definitely Gaeji',
  43. 'Who cares, Bellyache is autistic',
  44. 'Absolutely',
  45. 'Probably',
  46. 'Not looking good',
  47. "I'd rather not say",
  48. "You don't want to know",
  49. 'God is telling me no, but...',
  50. ]
  51.  
  52. await context.send(random.choice(responses) + ", " + context.message.author.mention)
  53.  
  54. @client.command(name='numgame',
  55. brief='Guess a number between 1 and 100',
  56. pass_context=True)
  57. async def numgame(context):
  58. number = random.randint(1,100)
  59. guess = 4
  60. while guess != 0:
  61. await context.send('Pick a number between 1 and 100')
  62. msg = await client.wait_for('message', check=check(context.author), timeout=30)
  63. attempt = int(msg.content)
  64. if attempt > number:
  65. await context.send(str(guess) + ' guesses left...')
  66. await asyncio.sleep(1)
  67. await context.send('Try going lower')
  68. await asyncio.sleep(1)
  69. guess -= 1
  70. elif attempt < number:
  71. await context.send(str(guess) + ' guesses left...')
  72. await asyncio.sleep(1)
  73. await context.send('Try going higher')
  74. await asyncio.sleep(1)
  75. guess -=1
  76. elif attempt == number:
  77. await context.send('You guessed it! Good job!')
  78. break
  79. else:
  80. await context.send("You didn't get it")
  81.  
  82. @client.command(name='say',
  83. brief='Repeats your message',
  84. pass_context=True)
  85. async def on_message(context, *, mes):
  86. await context.send(mes)
  87. await context.message.delete()
  88.  
  89.  
  90.  
  91. # Moderation
  92. @client.command(name='kick',
  93. brief='Kicks user',
  94. aliases=['Kick'],
  95. pass_context=True)
  96. async def kick(context, member:discord.Member=None):
  97. # Errors
  98. if not member:
  99. await context.send('Please specify a member.')
  100. return
  101.  
  102. if member not in context.guild.members():
  103. await context.send('Member does not exist.')
  104. # Actual Kicking
  105. if context.author.guild_permissions.kick_members == True:
  106. await member.kick()
  107. await context.send(f"{member.mention} was kicked ")
  108. else:
  109. await context.send(context.message.author.mention + ", you don't have permission")
  110.  
  111. @client.command(name='ban',
  112. brief='Bans user',
  113. aliases=['Ban'],
  114. pass_context=True)
  115. async def ban(context, member: discord.Member, reason=None):
  116. if context.author.guild_permissions.ban_members == True:
  117. await member.ban()
  118. await context.send(f"{member.mention} was banned. Reason: " + reason)
  119. else:
  120. await context.send(context.message.author.mention + ", you don't have permission")
  121. @client.command(name='mute',
  122. brief='Gets rid of a pest',
  123. aliases=['shutup'],
  124. pass_context=True)
  125. async def mute(context, member: discord.Member):
  126. if context.author.guild_permissions.manage_roles == True:
  127. role = get(member.guild.roles, name='Muted')
  128. await member.add_roles(role)
  129. await context.send(f'{member.mention} was muted.')
  130. else:
  131. await context.send(context.message.author.mention + ", you don't have permission")
  132.  
  133. @mute.error
  134. async def mute_error(context, error):
  135. if isinstance(error, ConversionError):
  136. await context.send(context.message.channel, 'Please specify a member')
  137. else:
  138. raise error
  139.  
  140. @client.command(name='unmute',
  141. brief='Test your luck',
  142. aliases=['unshutup'],
  143. pass_context=True)
  144. async def unmute(context, member: discord.Member):
  145. if member == None:
  146. await context.send(context.message.channel, 'Please specify a member')
  147. return
  148. if context.author.guild_permissions.manage_roles == True:
  149. role = get(member.guild.roles, name='Muted')
  150. await member.remove_roles(role)
  151. await context.send(f'{member.mention} was unmuted.')
  152. else:
  153. await context.send(context.message.author.mention + ", you don't have permission")
  154.  
  155. #@unmute.error
  156. #async def unmute_error(context, error):
  157. #if isinstance(error, ConversionError):
  158. #await context.send(context.message.channel, 'Please specify a member')
  159. #else:
  160. #raise error
  161.  
  162. # to do
  163. @client.command(name='unban',
  164. brief='Unbans user',
  165. aliases=['Unban'],
  166. pass_context=True)
  167.  
  168.  
  169. # Main --- Events
  170. @client.event
  171. async def on_member_join(member):
  172. channel = 546309900335316992
  173. await channel.send(str(member)+" joined")
  174.  
  175.  
  176. # Logs
  177.  
  178.  
  179. # Confirmation Kiss-shot is on
  180. @client.event
  181. async def on_ready():
  182. game = discord.Game('Prefix = k!')
  183. await client.change_presence(status=discord.Status.idle, activity=game)
  184. print("You're logged in as " + client.user.name)
  185. client.run(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement