Advertisement
qspitzer

11-9-17

Nov 9th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord.ext.commands import Bot
  4. import threading
  5. from threading import Thread
  6. import time
  7. import os
  8. import asyncio
  9. import random
  10.  
  11. bot = Bot(command_prefix='$', pm_help=True)
  12. client = discord.Client()
  13.  
  14. def serverCommands():
  15. while 1==1:
  16. scommand = input("> ")
  17. if scommand == "quit":
  18. os._exit(1)
  19.  
  20. bot.command()
  21. async def game(*, game: str):
  22. await bot.change_presence(game=discord.Game(name=game))
  23. await bot.say("Game changed to: " +game)
  24.  
  25. @bot.event
  26. async def on_ready():
  27. print('CaffeineBot connected through user {0}'.format(bot.user.name))
  28. s = Thread(target=serverCommands)
  29. s.start
  30.  
  31. @bot.command()
  32. async def ping():
  33. "A useless command"
  34. await bot.say("Pong!")
  35.  
  36. @bot.command()
  37. async def pong():
  38. "An even more useless command"
  39. await bot.say("Ping!")
  40.  
  41. @bot.command(pass_context=True)
  42. async def mention(ctx):
  43. author = discord.User.mention(name=ctx.message.author)
  44. await bot.say(author)
  45.  
  46. @bot.command(pass_context = True)
  47. async def clear(ctx, number):
  48. '''Clears previous messages'''
  49. number = int(number) #Converting the amount of messages to delete to an integer
  50. counter = 0
  51. async for x in bot.logs_from(ctx.message.channel, limit = number):
  52. if counter <= number:
  53. await bot.delete_message(x)
  54. counter += 1
  55. await asyncio.sleep(1.2)
  56.  
  57. @bot.command(pass_context=True)
  58. async def channel(ctx):
  59. client.create_channel(ctx.message.server, 'test', type=discord.ChannelType.text)
  60.  
  61. def startBot():
  62. bot.run('token')
  63.  
  64.  
  65. u = Thread(target=startBot)
  66. u.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement