Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.62 KB | None | 0 0
  1. import discord
  2. from discord.ext import tasks, commands #these are all for discord stuff
  3. import datetime
  4.  
  5. import requests #for communicating with APIs (primarily backpack.tf's)
  6. import json #used for formatting json, usually returned from APIs
  7.  
  8.  
  9. print(discord.__version__)
  10. print("\n") #cause linesplits are cool
  11. command_prefix = '$' #can be edited for quick changing of the prefix
  12.  
  13. bot = commands.Bot(command_prefix = command_prefix)
  14. bot.remove_command('help')
  15.  
  16. #loading extensions
  17. bot.load_extension('commands.cogs.unupc.unupc') #unusual price check command
  18. bot.load_extension('commands.cogs.pphelp.pphelp') #contains a listener that gives help regarding paypal trading when certain trigger words are detected in given channels, and a command that does the same manually
  19. bot.load_extension('commands.cogs.welcomes.welcomes') #contains a listener that sends a custom welcome message whenever a member joins the server
  20. bot.load_extension('commands.cogs.presence.presence') #contains the code that alternates the bot's presence
  21. bot.load_extension('commands.cogs.pinghelp.pinghelp') #sends a message if the trading advice role is pinged without links
  22. bot.load_extension('commands.cogs.pin.pin') #pins a given message to a channel
  23.  
  24. @bot.event
  25. async def on_ready():
  26.     print(f'Bot started running at {datetime.datetime.now()}')
  27.  
  28.  
  29. #HANDY FUNCTIONS 'N SHIT
  30.  
  31. def checkifmod(ctx): #checks if the sender of the message is a moderator
  32.         for role in ctx.author.roles:
  33.             if role.id == 334151916756008961: #role matches with
  34.                 return True
  35.         return False
  36.  
  37. def checkifbotowner(ctx): #checks if the sender of the message is the owner of the bot
  38.     if ctx.author.id == 226441515914756097:
  39.         return True
  40.  
  41.  
  42. #COMMANDS
  43.  
  44. @bot.command()
  45. async def crash(ctx): #stops the bot, the bat file it's launched from ensures it's rebooted
  46.     if checkifbotowner(ctx) == True:
  47.         await ctx.send("Bot stopped, rebooting")
  48.         raise SystemExit
  49.     else: #if the user isn't the bot owner
  50.         await ctx.send("Only the bot owner (Ques) can use this")
  51.  
  52.  
  53.  
  54. @bot.command()
  55. async def reload(ctx, extension): #reloads the given extension
  56.     if checkifbotowner(ctx) == True: #checks if the user is the bot owner
  57.         try: #tries the primary command folder first, then the cog folder
  58.             bot.reload_extension(f'commands.{extension}.{extension}')
  59.         except:
  60.             bot.reload_extension(f'commands.cogs.{extension}.{extension}')
  61.     else:
  62.         await ctx.send("Only the bot owner (Ques) can use this")
  63.  
  64.  
  65.  
  66. @bot.command()
  67. async def help(ctx): #sends a help message
  68.     embed = discord.Embed(title="Command list", description=f"Prefix: {command_prefix}", color=0xc40e26)
  69.  
  70.     embed.add_field(name=f"{command_prefix}help", value="Lists all bot commands (duh)")
  71.     embed.add_field(name=f"{command_prefix}pin", value="``[MOD COMMAND]`` Include a message ID to save it to a special channel") #PIN
  72.     embed.add_field(name=f"{command_prefix}unupc", value="Price checks an unusual. Syntax is ``effectname.hatname``. (This command is under construction and has been known to not work with certain effects. Report any bugs to the bot owner)")
  73.     embed.add_field(name=f"{command_prefix}refreshprices", value=f"Updates the prices used by {command_prefix}unupc. This will soon be done automatically every 2 hours")
  74.     embed.set_footer(text="TF2 Trade Central Slave version -497, created by ya boi Quesamo (patent pending)")
  75.     await ctx.send(embed=embed)
  76.  
  77.  
  78. with open('discord_api_key.txt', 'r') as discord_api_key:
  79.     discord_api_key = discord_api_key.read() #reads the file
  80.     bot.run(discord_api_key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement