daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2. from discord.ext.commands import Bot
  3. from discord.ext import commands
  4.  
  5.  
  6. Client = discord.Client()
  7. client = commands.Bot(command_prefix="?")
  8.  
  9.  
  10. client.remove_command('help')
  11.  
  12. @client.event
  13. async def on_ready():
  14.     await client.change_presence(game=discord.Game(name="Offical IT Install Nightmares & Greatness Bot"))
  15.     print("Bot Online!")
  16.     print("Name:  {}".format(client.user.name))
  17.     print("ID:    {}".format(client.user.id))
  18.  
  19.  
  20. @client.event
  21. async def on_message(message):
  22.     serverId = message.server.id
  23.  
  24.     iconLink = "https://scontent-lhr3-1.xx.fbcdn.net/v/t1.0-1/c33.0.200.200a/p200x200/23231431_1965953927026748_7444161055958677993_n.jpg?_nc_cat=110&_nc_ht=scontent-lhr3-1.xx&oh=f951768f21bbfede594b3a6b17093d93&oe=5C93EEE2"
  25.     authorName = "IT Install Nightmares"
  26.     embedTitle = "Let Me Google That For You...."
  27.     workingChannel = message.channel.id
  28.  
  29.     with open(serverId + ".txt", "a") as file:
  30.         placeholder = ""
  31.  
  32.     with open(serverId + ".txt", "r") as file:
  33.         for count, line in enumerate(file):
  34.             if count == 0:
  35.                 iconLink = line
  36.             elif count == 1:
  37.                 authorName = line
  38.             elif count == 2:
  39.                 embedTitle = line
  40.             elif count == 3:
  41.                 workingChannel = line
  42.  
  43.  
  44.     if message.channel.id == workingChannel:
  45.         if message.content.endswith("?"):
  46.             messageSplit = message.content.split(" ")
  47.             lmgtfy = "http://lmgtfy.com/?q="
  48.             for count, item in enumerate(messageSplit):
  49.                 if count > 0:
  50.                     if count < len(messageSplit) - 1:
  51.                         item += "+"
  52.                     lmgtfy += item
  53.                 else:
  54.                     getRidOfQuestionMark = ""
  55.                     for count2, item2 in enumerate(item):
  56.                         if count2 == 0:
  57.                             if item2 != "?":
  58.                                 getRidOfQuestionMark += item2
  59.                         else:
  60.                             getRidOfQuestionMark += item2
  61.                     if count < len(messageSplit) - 1:
  62.                         getRidOfQuestionMark += "+"
  63.                     lmgtfy += getRidOfQuestionMark
  64.             help = discord.Embed(title=embedTitle, description=lmgtfy, colour=0xDD2800)
  65.             help.set_author(name=authorName, icon_url=iconLink)
  66.             print(workingChannel)
  67.             await client.send_message(client.get_channel(workingChannel), embed=help)
  68.         else:
  69.             messageSplit = message.content.split(" ")
  70.             CarryOn = False;
  71.             for count, str in enumerate(messageSplit):
  72.                 if str.lower() == "how":
  73.                     if len(messageSplit)  > count:
  74.                         if messageSplit[count + 1] == "do":
  75.                             CarryOn = True
  76.             if CarryOn:
  77.                 lmgtfy = "http://lmgtfy.com/?q="
  78.                 for count, item in enumerate(messageSplit):
  79.                     if count > 0:
  80.                         if count < len(messageSplit) - 1:
  81.                             item += "+"
  82.                         lmgtfy += item
  83.                     else:
  84.                         getRidOfQuestionMark = ""
  85.                         for count2, item2 in enumerate(item):
  86.                             if count2 == 0:
  87.                                 if item2 != "?":
  88.                                     getRidOfQuestionMark += item2
  89.                             else:
  90.                                 getRidOfQuestionMark += item2
  91.                         if count < len(messageSplit) - 1:
  92.                             getRidOfQuestionMark += "+"
  93.                         lmgtfy += getRidOfQuestionMark
  94.                 help = discord.Embed(title=embedTitle, description=lmgtfy, colour=0xDD2800)
  95.                 help.set_author(name=authorName, icon_url=iconLink)
  96.                 await client.send_message(client.get_channel(workingChannel), embed=help)
  97.  
  98.     newiconLink = ""
  99.     newauthorName = ""
  100.     newembedTitle = ""
  101.     newworkingChannel = ""
  102.  
  103.     if message.content.startswith("?"):
  104.         if message.author.server_permissions.administrator:
  105.             print("Reached")
  106.             if message.content.lower().startswith("?seticonlink"):
  107.                 msgsplit = message.content.split(" ")
  108.                 for count5, str5 in enumerate(msgsplit):
  109.                     if count5 != 0:
  110.                         newiconLink += str5 + " "
  111.             elif message.content.lower().startswith("?setauthorname"):
  112.                 msgsplit = message.content.split(" ")
  113.                 for count5, str5 in enumerate(msgsplit):
  114.                     if count5 != 0:
  115.                         newauthorName += str5 + " "
  116.             elif message.content.lower().startswith("?embedtitle"):
  117.                 msgsplit = message.content.split(" ")
  118.                 for count5, str5 in enumerate(msgsplit):
  119.                     if count5 != 0:
  120.                         newembedTitle += str5 + " "
  121.             elif message.content.lower().startswith("?setcurrentchannel"):
  122.                 newworkingChannel = message.channel.id
  123.             else:
  124.                 unknownCMD = "Unknown CMD, try one of the following: \n ?seticonlink \n ?setauthorname \n ?embedtitle \n ?setcurrentchannel"
  125.                 help = discord.Embed(title="Unknown Command", description=unknownCMD, colour=0xDD2800)
  126.                 help.set_author(name=authorName, icon_url=iconLink)
  127.                 await client.send_message(message.channel, embed=help)
  128.             with open(serverId + ".txt", "w") as file:
  129.  
  130.                 if newiconLink != "":
  131.                     file.write(newiconLink)
  132.                 else:
  133.                     file.write(iconLink.strip("\n"))
  134.  
  135.                 if newauthorName != "":
  136.                     file.write("\n" + newauthorName)
  137.                 else:
  138.                     file.write("\n" + authorName.strip("\n"))
  139.  
  140.                 if newembedTitle != "" :
  141.                     file.write("\n" + newembedTitle)
  142.                 else:
  143.                     file.write("\n" + embedTitle.strip("\n"))
  144.  
  145.                 if newworkingChannel != "":
  146.                     file.write("\n" + newworkingChannel)
  147.                 else:
  148.                     file.write("\n" + workingChannel.strip("\n"))
  149.  
  150.  
  151. print("test")
  152. client.run("BotCode")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top