Guest User

Untitled

a guest
Jul 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import json
  4. import sqlite3
  5.  
  6. startup_extensions = ['moderator']
  7.  
  8. conn = sqlite3.connect('database.db')
  9. c = conn.cursor()
  10.  
  11. c.execute("""CREATE TABLE IF NOT EXISTS mod_log(
  12. action TEXT,
  13. user INTEGER,
  14. reason BLOB
  15. )""")
  16.  
  17. conn.commit()
  18.  
  19. with open('settings.json') as db:
  20. db = json.load(db)
  21.  
  22. PREFIX = db['prefix']
  23. DESCRIPTION = db['des']
  24. TOKEN = db['token']
  25.  
  26. bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION)
  27. bot.remove_command('help')
  28.  
  29. @bot.event
  30. async def on_ready():
  31. print("Up and running!")
  32. print("User ID:" + bot.user.id)
  33. print("Logged in as: " + bot.user.name)
  34.  
  35. @bot.event
  36. async def on_message(message):
  37. if message.content.upper().startswith('--WELCOME'):
  38. E = discord.Embed(title="Thanks!", description="I'm Imperial King and this is my server.", color = 0xFFFF00)
  39. E.set_footer(text = "This bot is created by Layoffin#9724")
  40. await bot.send_message(message.channel, embed = E)
  41. await bot.process_commands(message)
  42.  
  43. @bot.event
  44. async def on_member_join(member: discord.Member):
  45. logs = member.server.get_channel("426253928955379712")
  46. E = discord.Embed(title="Member Joined!", description="{} just joined! Make sure you read the rules and Follow them.".format(member.mention), color=0x00FF00)
  47. E.set_thumbnail(url=member.avatar_url)
  48. await bot.send_message(logs, embed = E)
  49.  
  50. @bot.event
  51. async def on_member_remove(member: discord.Member):
  52. logs = member.server.get_channel("426253928955379712")
  53. E = discord.Embed(title="Member Left!", description="{} just left us! sad :(".format(member))
  54. E.set_thumbnail(url=member.avatar_url)
  55. await bot.send_message(logs, embed = E)
  56.  
  57.  
  58. if __name__ == '__main__':
  59. for extension in startup_extensions:
  60. try:
  61. bot.load_extension(extension)
  62. except Exception as e:
  63. ex = '{}: {}'.format(type(e).__name__, e)
  64. print("Failed to load extension {} \n {}".format(extension, ex))
  65.  
  66. bot.run(TOKEN)
Add Comment
Please, Sign In to add comment