from discord.ext import commands, menus
import utils
import random , discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy
import traceback, textwrap
from discord.ext.menus.views import ViewMenuPages

class Owner(commands.Cog):
  def __init__(self, bot):
    self.bot = bot

  @commands.command(brief="a command to send mail")
  async def mail(self, ctx, *, user: utils.BetterUserconverter = None):
    if user is None:
      await ctx.reply("User not found, returning Letter")
      user = ctx.author
    if user:
      await ctx.reply("Please give me a message to use.")
      message = await self.bot.wait_for("message",check = utils.check(ctx))
      embed_message = discord.Embed(title=message.content, timestamp=(message.created_at), color=random.randint(0, 16777215))
      embed_message.set_author(name=f"Mail from: {ctx.author}",icon_url=(ctx.author.display_avatar.url))
      embed_message.set_footer(text = f"{ctx.author.id}")
      embed_message.set_thumbnail(url = "https://i.imgur.com/1XvDnqC.png")
      if (user.dm_channel is None):
        await user.create_dm()
      try:
        await user.send(embed=embed_message)
      except:
        user = ctx.author
        await user.send(content="Message failed. sending",embed=embed_message)
        embed_message.add_field(name="Sent To:",value=str(user))
      await self.bot.get_channel(855217084710912050).send(embed=embed_message)

  @commands.command()
  async def load(self, ctx, *, cog = None):
    if cog:
      try:
        self.bot.load_extension(cog)
      except Exception as e:
        await ctx.send(e)
        traceback.print_exc()

      await ctx.send("Loaded cog(see if there's any errors)")

    if cog is None:
      await ctx.send("you can't ask to load no cogs.")
  
  @commands.command()
  async def reload(self, ctx, *, cog = None):
    
    cog = cog or "all"

    if cog == "all":
      for x in list(self.bot.extensions):
        try:
          self.bot.reload_extension(x)
        except commands.errors.ExtensionError as e:
          await ctx.send(e)
          traceback.print_exc()

      await ctx.send("done reloading all cogs(check for any errors)")

    else:
      try:
        self.bot.reload_extension(cog)

      except commands.errors.ExtensionError as e:
        await ctx.send(e)
        traceback.print_exc()

      await ctx.send("Cog reloaded :D (check for any errors)")
  
  @commands.command()
  async def unload(self, ctx, *, cog = None):
    if cog:
      try:
        self.bot.unload_extension(cog)
      except commands.errors.ExtensionError as e:
        await ctx.send(e)
        traceback.print_exc()
      await ctx.send("Cog should be unloaded just fine :D.(check any errors)")
    if cog is None:
      await ctx.send("you can't ask to reload no cogs")

  @commands.command()
  async def shutdown(self, ctx):
    await ctx.send("shutdown/logout time happening.")
    await self.bot.close()

  async def cog_check(self, ctx):
    return await self.bot.is_owner(ctx.author)

  async def cog_command_error(self, ctx, error):
    if ctx.command or not ctx.command.has_error_handler():
      await ctx.send(error)
      
      traceback.print_exc()

    #I need to fix all cog_command_error

  @commands.command(brief="Changes Bot Status(Owner Only)")
  async def status(self , ctx , * , args=None):
    if await self.bot.is_owner(ctx.author):
      if args:
        await self.bot.change_presence(status=discord.Status.do_not_disturb, activity= discord.Activity(type=discord.ActivityType.watching,name=args))
      if args is None:
        await self.bot.change_presence(status=discord.Status.do_not_disturb)
    if await self.bot.is_owner(ctx.author) is False:
      await ctx.send("That's an owner only command")
  
  @commands.command(brief="Only owner command to change bot's nickname")
  async def change_nick(self, ctx ,*, name=None):
    if await self.bot.is_owner(ctx.author):
      if isinstance(ctx.channel, discord.TextChannel):
        await ctx.send("Changing Nickname")
        try:
          await ctx.guild.me.edit(nick=name)
        except discord.Forbidden:
          await ctx.send("Appears not to have valid perms")
      if isinstance(ctx.channel,discord.DMChannel):
        await ctx.send("You can't use that in Dms.")
      
    if await self.bot.is_owner(ctx.author) is False:
      await ctx.send("You can't use that command")

  class ServersEmbed(menus.ListPageSource):
    async def format_page(self, menu, item):
      embed = discord.Embed(title="Servers:",description=item,color=random.randint(0, 16777215))
      return embed
  
  @commands.command(brief="a command to give a list of servers(owner only)",help="Gives a list of guilds(Bot Owners only)")
  async def servers(self, ctx):
    if await self.bot.is_owner(ctx.author):

      pag = commands.Paginator()
      for g in self.bot.guilds:
       pag.add_line(f"[{len(g.members)}/{g.member_count}] **{g.name}** (`{g.id}`) | {(g.system_channel or g.text_channels[0]).mention}")

      pages = [page.strip("`") for page in pag.pages]
      menu = ViewMenuPages(self.ServersEmbed(pages, per_page=1),delete_message_after=True)

      if (ctx.author.dm_channel is None):
        await ctx.author.create_dm()

      await menu.start(ctx, channel = ctx.author.dm_channel)
      
    if await self.bot.is_owner(ctx.author) is False:
      await ctx.send("You can't use that it's owner only")

  @commands.command(brief="only works with JDJG, but this command is meant to send updates to my webhook")
  async def webhook_update(self, ctx, *, args = None):
    if await self.bot.is_owner(ctx.author):
      if args:
        if isinstance(ctx.channel, discord.TextChannel):
          try:
            await ctx.message.delete()
          
          except:
            await ctx.send("It couldn't delete the message in this guils so, I kept it here.")

        webhook = discord.Webhook.from_url(os.environ["webhook1"], session = self.bot.session)
        embed=discord.Embed(title="Update",color=(35056),timestamp=(ctx.message.created_at))
        embed.add_field(name="Update Info:",value=args)
        embed.set_author(name="JDJG's Update",icon_url='https://i.imgur.com/pdQkCBv.png')
        embed.set_footer(text="JDJG's Updates")
        await webhook.send(embed=embed)
      
        webhook=discord.Webhook.from_url(os.environ["webhook99"], session = self.bot.session)
        embed=discord.Embed(title="Update",color=(35056),timestamp=(ctx.message.created_at))
        embed.add_field(name="Update Info:",value=args)
        embed.set_author(name="JDJG's Update",icon_url='https://i.imgur.com/pdQkCBv.png')
        embed.set_footer(text="JDJG's Updates")
        await webhook.send(embed=embed)

      if args is None:
        await ctx.send("You sadly can't use it like that.")
    if await self.bot.is_owner(ctx.author) is False:
      await ctx.send("You can't use that")

  @commands.command(brief="Commands to see what guilds a person is in.")
  async def mutualguilds(self, ctx, *, user: utils.BetterUserconverter = None):
    user = user or ctx.author
    pag = commands.Paginator()

    for g in user.mutual_guilds:
      pag.add_line(f"{g}")

    pages = [page.strip("`") for page in pag.pages]
    pages = pages or ["No shared servers"]

    menu = ViewMenuPages(utils.mutualGuildsEmbed(pages, per_page=1),delete_message_after = True)

    if (ctx.author.dm_channel is None):
        await ctx.author.create_dm()

    await menu.start(ctx, channel = ctx.author.dm_channel)

  @commands.command(brief="A command to add sus_users with a reason")
  async def addsus(self, ctx, *, user: utils.BetterUserconverter = None):
    if user is None:
      await ctx.send("can't have a user be none.")

    if user:
      await ctx.reply("Please give me a reason why:")
      reason = await self.bot.wait_for("message",check= utils.check(ctx))
      cur = await self.bot.sus_users.cursor()
      await cur.execute("INSERT INTO sus_users VALUES (?, ?)", (user.id, reason.content))
      await self.bot.sus_users.commit()
      await cur.close()
      await ctx.send("added sus users, succesfully")

  @commands.command(brief="a command to remove sus users.")
  async def removesus(self, ctx, *, user: utils.BetterUserconverter = None):
    if user is None:
      await ctx.send("You can't have a none user.")

    if user:
      cur = await self.bot.sus_users.cursor()
      await cur.execute("DELETE FROM sus_users WHERE user_id = ?", (user.id,))
      await self.bot.sus_users.commit()
      await cur.close()
      await ctx.send("Removed sus users.")

  class SusUsersEmbed(menus.ListPageSource):
    async def format_page(self, menu, item):
      embed=discord.Embed(title = "Users Deemed Suspicious by JDJG Inc. Official", color = random.randint(0, 16777215))
      embed.add_field(name = f"User ID : {item[0]}", value = f"**Reason :** {item[1]}", inline = False)
      return embed

  @commands.command(brief="a command to grab all in the sus_users list")
  async def sus_users(self, ctx):
    cur = await self.bot.sus_users.cursor()
    cursor = await cur.execute("SELECT * FROM SUS_USERS;")
    sus_users = tuple(await cursor.fetchall())
    await cur.close()
    await self.bot.sus_users.commit()  
    menu = ViewMenuPages(self.SusUsersEmbed(sus_users, per_page=1),delete_message_after=True)
    await menu.start(ctx)

  @sus_users.error
  async def sus_users_error(self, ctx, error):
    await ctx.send(error)


  class TestersEmbed(menus.ListPageSource):
    async def format_page(self, menu, item):
      embed = discord.Embed(title = "Testing Users:", color = random.randint(0, 16777215))
      embed.add_field(name = "User ID:", value = f"{item}", inline = False)
      
      return embed

  @commands.command(brief = "a command listed all the commands")
  async def testers(self, ctx):

    menu = ViewMenuPages(self.TestersEmbed(self.bot.testers, per_page = 1), delete_message_after = True)
    await menu.start(ctx)

  @commands.command()
  async def update_sus(self, ctx):
    await self.bot.sus_users.commit()
    await ctx.send("Updated SQL boss.")

  @update_sus.error
  async def update_sus_error(self, ctx, error):
    await ctx.send(error)

  @commands.command(aliases=["bypass_command"])
  async def command_bypass(self, ctx ,user: utils.BetterUserconverter = None, *, command = None):
    #make sure to swap to autoconverter if it gets added.
    user = user or ctx.author
    if command:
      command_wanted=self.bot.get_command(command)
      if command_wanted:
        await ctx.send(f"{command_wanted.name} now accessible for the {user} for one command usage!")
        self.bot.special_access[user.id]=command_wanted.name
      if command_wanted is None:
        await ctx.send("Please specify a valid command.")
    if command is None:
      await ctx.send("select a command :(")

  @commands.command(brief = "resets cooldown for you.",aliases = ["reset_cooldown"])
  async def resetcooldown(self, ctx, *, command = None):
    if not command:
      return await ctx.send("please specificy a command")
    
    command_wanted = self.bot.get_command(command)

    if not command_wanted:
      return await ctx.send("please specify a command")

    if not command_wanted.is_on_cooldown(ctx):
      return await ctx.send("That doesn't have a cooldown/isn't on a cooldown.")

    command_wanted.reset_cooldown(ctx)
    await ctx.send(f"reset cooldown of {command_wanted}")

  @commands.command(brief = "leaves a guild only use when needed or really wanted. Otherwise no thanks.")
  async def leave_guild(self, ctx, *, guild: typing.Optional[discord.Guild] = None):
    guild = guild or ctx.guild
    if guild is None: return await ctx.send("Guild is None can't do anything.")
    await ctx.send("Bot leaving guild :(")
    try:
     await guild.leave()
    
    except Exception as e:
      await ctx.send(f"Somehow an error occured: {e}")
      traceback.print_exc()
  
  @commands.command()
  async def aioinput_test(self, ctx, *, args = None):
    args = args or "Test"

    result=await self.bot.loop.run_in_executor(None, input, (f"{args}:"))
    await ctx.send(f"Result of the input was {result}")

  @commands.command(brief="a powerful owner tool to reload local files that aren't reloadable.")
  async def reload_basic(self, ctx, *, args = None):
    if args is None:await ctx.send("Can't reload module named None")

    if args:
      try: module = importlib.import_module(name=args)
      except Exception as e:
        traceback.print_exc()
        return await ctx.send(e)

      try: value=importlib.reload(module)
      except Exception as e: 
        traceback.print_exc()
        return await ctx.send(e)

      await ctx.send(f"Sucessfully reloaded {value.__name__} \nMain Package: {value.__package__}")


  @commands.command(brief="backs up a channel and then sends it into a file or mystbin")
  async def channel_backup(self, ctx):

    messages = await ctx.channel.history(limit = None, oldest_first = True).flatten()

    new_line = "\n"
    
    page = "\n".join(f"{msg.author} ({('Bot' if msg.author.bot else 'User')}) : {msg.content} {new_line}Attachments : {msg.attachments}" if msg.content else f"{msg.author} ({('Bot' if msg.author.bot else 'User')}) : {new_line.join(f'{e.to_dict()}' for e in msg.embeds)} {new_line}Attachments : {msg.attachments}" for msg in messages)

    mystbin_client = mystbin.Client(session = self.bot.session)
    paste = await mystbin_client.post(page)

    await ctx.author.send(content=f"Added text file to mystbin: \n{paste.url}")

  @channel_backup.error
  async def channel_backup_error(self, ctx, error):
    etype = type(error)
    trace = error.__traceback__

    values=''.join(map(str,traceback.format_exception(etype, error, trace)))
 
    pages = textwrap.wrap(values, width = 1992)

    menu = ViewMenuPages(utils.ErrorEmbed(pages, per_page = 1),delete_message_after = True)

    if (ctx.author.dm_channel is None):
      await ctx.author.create_dm()

    await menu.start(ctx, channel = ctx.author.dm_channel)

    mystbin_client = mystbin.Client(session=self.bot.session)
    paste = await mystbin_client.post(values)

    await ctx.send(f"Traceback: {paste.url}")

  @commands.command(brief = "adds packages and urls to rtfm DB", aliases=["add_rtfm"])
  async def addrtfm(self, ctx, name = None, *, url = None):
    if not name or not url or not name and not url:
      return await ctx.send("You need a name and also url.")

    cur = await self.bot.sus_users.cursor()
    await cur.execute("INSERT INTO RTFM_DICTIONARY VALUES (?, ?)", (name, url))
    await self.bot.sus_users.commit()
    await cur.close()

    await ctx.send(f"added {name} and {url} to the rtfm DB")

  @commands.command(brief = "removes packages from the rtfm DB", aliases = ["remove_rtfm"])
  async def removertfm(self, ctx, *, name = None):
    if name is None:
      return await ctx.send("You can't remove None")

    cur = await self.bot.sus_users.cursor()
    await cur.execute("DELETE FROM RTFM_DICTIONARY WHERE name = ?", (name,))
    await self.bot.sus_users.commit()
    await cur.close()
    await ctx.send(f"Removed the rfm value {name}.")

  @commands.command(brief = "a command to save images to imgur(for owner only lol)")
  async def save_image(self, ctx):
    if not ctx.message.attachments:
      return await ctx.send("You need to provide some attachments.")

    await ctx.send("JDJG doesn't take any responbility for what you upload here :eyes: don't upload anything bad okay?")

    for x in ctx.message.attachments:
      try:
        discord.utils._get_mime_type_for_image(await x.read())

      except Exception as e:
        traceback.print_exc()
        return await ctx.send(e)

      
      imgur_client= aioimgur.ImgurClient(os.environ["imgur_id"], os.environ["imgur_secret"])

      imgur_url = await imgur_client.upload(await x.read())
      await ctx.send(f"{imgur_url['link']}")

  @commands.command(brief="A command to remove testers")
  async def remove_tester(self, ctx, *, user: utils.BetterUserconverter = None):
    if user is None:
      await ctx.send("You can't have a non existent user.")

    if user:
      cur = await self.bot.sus_users.cursor()
      await cur.execute("DELETE FROM testers_list WHERE user_id = ?", (user.id,))
      await self.bot.sus_users.commit()
      await cur.close()
      
      if not user.id in self.bot.testers: 
        return await ctx.send(f"{user} isn't in the testers list.")

      else:
        self.bot.testers.remove(user.id)
        await ctx.send(f"Removed tester known as {user}")

  @commands.command(brief="A command to add testers")
  async def add_tester(self, ctx, *, user: utils.BetterUserconverter = None):
    if user is None:
      await ctx.send("You can't have a non existent user.")

    if user:
      cur = await self.bot.sus_users.cursor()
      await cur.execute("INSERT INTO testers_list VALUES (?)", (user.id,))
      await self.bot.sus_users.commit()
      await cur.close()
      
      if not user.id in self.bot.testers: 
        self.bot.testers.append(user.id)
        await ctx.send(f"added tester known as {user}")

      else:
        return await ctx.send(f"{user} is in the testers list already!")

  def tweepy_post(self, post_text = None):

    consumer_key = os.getenv('tweet_key')
    consumer_secret = os.getenv('tweet_secret')

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

    access_token = os.getenv('tweet_access')
    access_secret = os.getenv('tweet_token')

    auth.set_access_token(access_token, access_secret)

    twitter_api = tweepy.API(auth)

    return twitter_api.update_status(status = post_text)

  @commands.command(brief = "sends tweet to JDBot Twitter")
  async def send_tweet(self, ctx, *, args = None):
    
    if not args:
      return await ctx.send("you can't send nothing to twitter.")

    try:
      tweet_time = functools.partial(self.tweepy_post, args)
      post = await self.bot.loop.run_in_executor(None, tweet_time)
      
    except Exception as e:
      traceback.print_exc()
      return await ctx.send(f"Exception occured at {e}")

    await ctx.send(f"Url of sent tweet is: https://twitter.com/twitter/statuses/{post.id}")

  @commands.command(brief = "chunks a guild for the purpose of testing purpose(it's owner only to be used in testing guilds only)")
  async def chunk_guild(self, ctx):
    if ctx.guild is None:
      return await ctx.send("You can't chunk a guild that doesn't exist or a channel that is a DM.")

    if ctx.guild.chunked:
      return await ctx.send("No need to chunk this guild, it appears to be chunked")

    await ctx.guild.chunk(cache = True)

    await ctx.send("Finished chunking..")

  @chunk_guild.error
  async def chunk_guild_error(self, ctx, error):
    await ctx.send(error)
    traceback.print_exc()

  
  @commands.command(brief = "displays the guild status and user status immediately")
  async def stats_status(self, ctx):
    await ctx.send("changing status, check now....")
    
    await self.bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.watching, name=f"{len(self.bot.guilds)} servers | {len(self.bot.users)} users"))


  @stats_status.error
  async def stats_status_error(self, ctx, error):
    await ctx.send(error) 

  @commands.command(brief="a command to give a list of servers(owner only)",help="Gives a list of guilds(Bot Owners only) but with join dates updated.")
  async def servers2(self, ctx):
    if await self.bot.is_owner(ctx.author):

      sorted_guilds = sorted(self.bot.guilds, key=lambda guild: guild.me.joined_at)

      pag = commands.Paginator()
      for g in sorted_guilds:
       pag.add_line(f"{discord.utils.format_dt(g.me.joined_at, style = 'd')} {discord.utils.format_dt(g.me.joined_at, style = 'T')} \n[{len(g.members)}/{g.member_count}] **{g.name}** (`{g.id}`) | {(g.system_channel or g.text_channels[0]).mention}\n")

      pages = [page.strip("`") for page in pag.pages]
      menu = ViewMenuPages(self.ServersEmbed(pages, per_page=1),delete_message_after=True)

      if (ctx.author.dm_channel is None):
        await ctx.author.create_dm()

      await menu.start(ctx, channel = ctx.author.dm_channel)
      
    if await self.bot.is_owner(ctx.author) is False:
      await ctx.send("You can't use that it's owner only")
  

def setup(bot):
  bot.add_cog(Owner(bot))

[((11, 3, 11, 51), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((33, 3, 33, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((47, 3, 47, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((72, 3, 72, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((84, 3, 84, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((100, 3, 100, 59), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((110, 3, 110, 72), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((130, 3, 130, 123), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((149, 3, 149, 106), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((179, 3, 179, 72), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((197, 3, 197, 69), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((211, 3, 211, 59), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((229, 3, 229, 72), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((251, 3, 251, 64), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((257, 3, 257, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((266, 3, 266, 47), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((280, 3, 280, 84), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((296, 3, 296, 105), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((308, 3, 308, 21), 'discord.ext.commands.command', 'commands.command', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((315, 3, 315, 96), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((333, 3, 333, 88), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((368, 3, 368, 86), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((380, 3, 380, 91), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((391, 3, 391, 84), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((412, 3, 412, 56), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((430, 3, 430, 53), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((464, 3, 464, 59), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((480, 3, 480, 131), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((498, 3, 498, 84), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((509, 3, 509, 152), 'discord.ext.commands.command', 'commands.command', (), '', False, 'from discord.ext import commands, menus\n'), ((182, 10, 182, 30), 'discord.ext.commands.Paginator', 'commands.Paginator', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((342, 21, 342, 63), 'mystbin.Client', 'mystbin.Client', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((354, 12, 354, 47), 'textwrap.wrap', 'textwrap.wrap', (), '', False, 'import traceback, textwrap\n'), ((363, 21, 363, 61), 'mystbin.Client', 'mystbin.Client', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((450, 19, 450, 41), 'os.getenv', 'os.getenv', ({(450, 29, 450, 40): '"""tweet_key"""'}, {}), "('tweet_key')", False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((451, 22, 451, 47), 'os.getenv', 'os.getenv', ({(451, 32, 451, 46): '"""tweet_secret"""'}, {}), "('tweet_secret')", False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((453, 11, 453, 61), 'tweepy.OAuthHandler', 'tweepy.OAuthHandler', ({(453, 31, 453, 43): 'consumer_key', (453, 45, 453, 60): 'consumer_secret'}, {}), '(consumer_key, consumer_secret)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((455, 19, 455, 44), 'os.getenv', 'os.getenv', ({(455, 29, 455, 43): '"""tweet_access"""'}, {}), "('tweet_access')", False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((456, 20, 456, 44), 'os.getenv', 'os.getenv', ({(456, 30, 456, 43): '"""tweet_token"""'}, {}), "('tweet_token')", False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((460, 18, 460, 34), 'tweepy.API', 'tweepy.API', ({(460, 29, 460, 33): 'auth'}, {}), '(auth)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((495, 4, 495, 25), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((96, 6, 96, 27), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((134, 12, 134, 32), 'discord.ext.commands.Paginator', 'commands.Paginator', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((190, 25, 190, 67), 'utils.mutualGuildsEmbed', 'utils.mutualGuildsEmbed', (), '', False, 'import utils\n'), ((356, 25, 356, 62), 'utils.ErrorEmbed', 'utils.ErrorEmbed', (), '', False, 'import utils\n'), ((407, 20, 407, 92), 'aioimgur.ImgurClient', 'aioimgur.ImgurClient', ({(407, 41, 407, 63): "os.environ['imgur_id']", (407, 65, 407, 91): "os.environ['imgur_secret']"}, {}), "(os.environ['imgur_id'], os.environ['imgur_secret'])", False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((471, 19, 471, 60), 'functools.partial', 'functools.partial', ({(471, 37, 471, 53): 'self.tweepy_post', (471, 55, 471, 59): 'args'}, {}), '(self.tweepy_post, args)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((515, 12, 515, 32), 'discord.ext.commands.Paginator', 'commands.Paginator', ({}, {}), '()', False, 'from discord.ext import commands, menus\n'), ((160, 18, 160, 94), 'discord.Webhook.from_url', 'discord.Webhook.from_url', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((161, 14, 161, 92), 'discord.Embed', 'discord.Embed', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((167, 16, 167, 93), 'discord.Webhook.from_url', 'discord.Webhook.from_url', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((168, 14, 168, 92), 'discord.Embed', 'discord.Embed', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((306, 6, 306, 27), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((320, 20, 320, 54), 'importlib.import_module', 'importlib.import_module', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((325, 17, 325, 41), 'importlib.reload', 'importlib.reload', ({(325, 34, 325, 40): 'module'}, {}), '(module)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((352, 27, 352, 74), 'traceback.format_exception', 'traceback.format_exception', ({(352, 54, 352, 59): 'etype', (352, 61, 352, 66): 'error', (352, 68, 352, 73): 'trace'}, {}), '(etype, error, trace)', False, 'import traceback, textwrap\n'), ((475, 6, 475, 27), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((19, 97, 19, 124), 'random.randint', 'random.randint', ({(19, 112, 19, 113): '0', (19, 115, 19, 123): '16777215'}, {}), '(0, 16777215)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((40, 8, 40, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((68, 8, 68, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((79, 8, 79, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((127, 68, 127, 95), 'random.randint', 'random.randint', ({(127, 83, 127, 84): '0', (127, 86, 127, 94): '16777215'}, {}), '(0, 16777215)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((225, 91, 225, 118), 'random.randint', 'random.randint', ({(225, 106, 225, 107): '0', (225, 109, 225, 117): '16777215'}, {}), '(0, 16777215)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((246, 62, 246, 89), 'random.randint', 'random.randint', ({(246, 77, 246, 78): '0', (246, 80, 246, 88): '16777215'}, {}), '(0, 16777215)', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((322, 8, 322, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((327, 8, 327, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((403, 8, 403, 29), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((18, 58, 18, 74), 'utils.check', 'utils.check', ({(18, 70, 18, 73): 'ctx'}, {}), '(ctx)', False, 'import utils\n'), ((58, 10, 58, 31), 'traceback.print_exc', 'traceback.print_exc', ({}, {}), '()', False, 'import traceback, textwrap\n'), ((204, 56, 204, 72), 'utils.check', 'utils.check', ({(204, 68, 204, 71): 'ctx'}, {}), '(ctx)', False, 'import utils\n'), ((104, 87, 104, 149), 'discord.Activity', 'discord.Activity', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((517, 23, 517, 75), 'discord.utils.format_dt', 'discord.utils.format_dt', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((517, 78, 517, 130), 'discord.utils.format_dt', 'discord.utils.format_dt', (), '', False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n')]