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))

[((293, 341), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command to send mail"""'}), "(brief='a command to send mail')\n", (309, 341), False, 'from discord.ext import commands, menus\n'), ((1418, 1436), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (1434, 1436), False, 'from discord.ext import commands, menus\n'), ((1771, 1789), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (1787, 1789), False, 'from discord.ext import commands, menus\n'), ((2401, 2419), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (2417, 2419), False, 'from discord.ext import commands, menus\n'), ((2793, 2811), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (2809, 2811), False, 'from discord.ext import commands, menus\n'), ((3226, 3282), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""Changes Bot Status(Owner Only)"""'}), "(brief='Changes Bot Status(Owner Only)')\n", (3242, 3282), False, 'from discord.ext import commands, menus\n'), ((3753, 3822), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""Only owner command to change bot\'s nickname"""'}), '(brief="Only owner command to change bot\'s nickname")\n', (3769, 3822), False, 'from discord.ext import commands, menus\n'), ((4596, 4721), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command to give a list of servers(owner only)"""', 'help': '"""Gives a list of guilds(Bot Owners only)"""'}), "(brief='a command to give a list of servers(owner only)',\n    help='Gives a list of guilds(Bot Owners only)')\n", (4612, 4721), False, 'from discord.ext import commands, menus\n'), ((5407, 5520), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""only works with JDJG, but this command is meant to send updates to my webhook"""'}), "(brief=\n    'only works with JDJG, but this command is meant to send updates to my webhook'\n    )\n", (5423, 5520), False, 'from discord.ext import commands, menus\n'), ((6895, 6964), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""Commands to see what guilds a person is in."""'}), "(brief='Commands to see what guilds a person is in.')\n", (6911, 6964), False, 'from discord.ext import commands, menus\n'), ((7503, 7569), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""A command to add sus_users with a reason"""'}), "(brief='A command to add sus_users with a reason')\n", (7519, 7569), False, 'from discord.ext import commands, menus\n'), ((8115, 8171), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command to remove sus users."""'}), "(brief='a command to remove sus users.')\n", (8131, 8171), False, 'from discord.ext import commands, menus\n'), ((8906, 8975), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command to grab all in the sus_users list"""'}), "(brief='a command to grab all in the sus_users list')\n", (8922, 8975), False, 'from discord.ext import commands, menus\n'), ((9723, 9782), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command listed all the commands"""'}), "(brief='a command listed all the commands')\n", (9739, 9782), False, 'from discord.ext import commands, menus\n'), ((9953, 9971), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (9969, 9971), False, 'from discord.ext import commands, menus\n'), ((10184, 10228), 'discord.ext.commands.command', 'commands.command', ([], {'aliases': "['bypass_command']"}), "(aliases=['bypass_command'])\n", (10200, 10228), False, 'from discord.ext import commands, menus\n'), ((10833, 10911), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""resets cooldown for you."""', 'aliases': "['reset_cooldown']"}), "(brief='resets cooldown for you.', aliases=['reset_cooldown'])\n", (10849, 10911), False, 'from discord.ext import commands, menus\n'), ((11421, 11531), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""leaves a guild only use when needed or really wanted. Otherwise no thanks."""'}), "(brief=\n    'leaves a guild only use when needed or really wanted. Otherwise no thanks.'\n    )\n", (11437, 11531), False, 'from discord.ext import commands, menus\n'), ((11918, 11936), 'discord.ext.commands.command', 'commands.command', ([], {}), '()\n', (11934, 11936), False, 'from discord.ext import commands, menus\n'), ((12152, 12250), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a powerful owner tool to reload local files that aren\'t reloadable."""'}), '(brief=\n    "a powerful owner tool to reload local files that aren\'t reloadable.")\n', (12168, 12250), False, 'from discord.ext import commands, menus\n'), ((12770, 12860), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""backs up a channel and then sends it into a file or mystbin"""'}), "(brief=\n    'backs up a channel and then sends it into a file or mystbin')\n", (12786, 12860), False, 'from discord.ext import commands, menus\n'), ((14182, 14268), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""adds packages and urls to rtfm DB"""', 'aliases': "['add_rtfm']"}), "(brief='adds packages and urls to rtfm DB', aliases=[\n    'add_rtfm'])\n", (14198, 14268), False, 'from discord.ext import commands, menus\n'), ((14690, 14779), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""removes packages from the rtfm DB"""', 'aliases': "['remove_rtfm']"}), "(brief='removes packages from the rtfm DB', aliases=[\n    'remove_rtfm'])\n", (14706, 14779), False, 'from discord.ext import commands, menus\n'), ((15143, 15222), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""a command to save images to imgur(for owner only lol)"""'}), "(brief='a command to save images to imgur(for owner only lol)')\n", (15159, 15222), False, 'from discord.ext import commands, menus\n'), ((15904, 15957), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""A command to remove testers"""'}), "(brief='A command to remove testers')\n", (15920, 15957), False, 'from discord.ext import commands, menus\n'), ((16560, 16610), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""A command to add testers"""'}), "(brief='A command to add testers')\n", (16576, 16610), False, 'from discord.ext import commands, menus\n'), ((17645, 17699), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""sends tweet to JDBot Twitter"""'}), "(brief='sends tweet to JDBot Twitter')\n", (17661, 17699), False, 'from discord.ext import commands, menus\n'), ((18195, 18331), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""chunks a guild for the purpose of testing purpose(it\'s owner only to be used in testing guilds only)"""'}), '(brief=\n    "chunks a guild for the purpose of testing purpose(it\'s owner only to be used in testing guilds only)"\n    )\n', (18211, 18331), False, 'from discord.ext import commands, menus\n'), ((18813, 18892), 'discord.ext.commands.command', 'commands.command', ([], {'brief': '"""displays the guild status and user status immediately"""'}), "(brief='displays the guild status and user status immediately')\n", (18829, 18892), False, 'from discord.ext import commands, menus\n'), ((19293, 19452), 'discord.ext.commands.command', '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."""'}), "(brief='a command to give a list of servers(owner only)',\n    help='Gives a list of guilds(Bot Owners only) but with join dates updated.'\n    )\n", (19309, 19452), False, 'from discord.ext import commands, menus\n'), ((7085, 7105), 'discord.ext.commands.Paginator', 'commands.Paginator', ([], {}), '()\n', (7103, 7105), False, 'from discord.ext import commands, menus\n'), ((13364, 13404), 'mystbin.Client', 'mystbin.Client', ([], {'session': 'self.bot.session'}), '(session=self.bot.session)\n', (13378, 13404), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((13757, 13790), 'textwrap.wrap', 'textwrap.wrap', (['values'], {'width': '(1992)'}), '(values, width=1992)\n', (13770, 13790), False, 'import traceback, textwrap\n'), ((14044, 14084), 'mystbin.Client', 'mystbin.Client', ([], {'session': 'self.bot.session'}), '(session=self.bot.session)\n', (14058, 14084), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17266, 17288), 'os.getenv', 'os.getenv', (['"""tweet_key"""'], {}), "('tweet_key')\n", (17275, 17288), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17311, 17336), 'os.getenv', 'os.getenv', (['"""tweet_secret"""'], {}), "('tweet_secret')\n", (17320, 17336), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17349, 17399), 'tweepy.OAuthHandler', 'tweepy.OAuthHandler', (['consumer_key', 'consumer_secret'], {}), '(consumer_key, consumer_secret)\n', (17368, 17399), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17420, 17445), 'os.getenv', 'os.getenv', (['"""tweet_access"""'], {}), "('tweet_access')\n", (17429, 17445), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17466, 17490), 'os.getenv', 'os.getenv', (['"""tweet_token"""'], {}), "('tweet_token')\n", (17475, 17490), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17566, 17582), 'tweepy.API', 'tweepy.API', (['auth'], {}), '(auth)\n', (17576, 17582), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((18784, 18805), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (18803, 18805), False, 'import traceback, textwrap\n'), ((3158, 3179), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (3177, 3179), False, 'import traceback, textwrap\n'), ((4806, 4826), 'discord.ext.commands.Paginator', 'commands.Paginator', ([], {}), '()\n', (4824, 4826), False, 'from discord.ext import commands, menus\n'), ((7289, 7331), 'utils.mutualGuildsEmbed', 'utils.mutualGuildsEmbed', (['pages'], {'per_page': '(1)'}), '(pages, per_page=1)\n', (7312, 7331), False, 'import utils\n'), ((13819, 13854), 'utils.ErrorEmbed', 'utils.ErrorEmbed', (['pages'], {'per_page': '(1)'}), '(pages, per_page=1)\n', (13835, 13854), False, 'import utils\n'), ((15721, 15793), 'aioimgur.ImgurClient', 'aioimgur.ImgurClient', (["os.environ['imgur_id']", "os.environ['imgur_secret']"], {}), "(os.environ['imgur_id'], os.environ['imgur_secret'])\n", (15741, 15793), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((17870, 17911), 'functools.partial', 'functools.partial', (['self.tweepy_post', 'args'], {}), '(self.tweepy_post, args)\n', (17887, 17911), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((19618, 19638), 'discord.ext.commands.Paginator', 'commands.Paginator', ([], {}), '()\n', (19636, 19638), False, 'from discord.ext import commands, menus\n'), ((5879, 5953), 'discord.Webhook.from_url', 'discord.Webhook.from_url', (["os.environ['webhook1']"], {'session': 'self.bot.session'}), "(os.environ['webhook1'], session=self.bot.session)\n", (5903, 5953), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((5970, 6046), 'discord.Embed', 'discord.Embed', ([], {'title': '"""Update"""', 'color': '(35056)', 'timestamp': 'ctx.message.created_at'}), "(title='Update', color=35056, timestamp=ctx.message.created_at)\n", (5983, 6046), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((6306, 6381), 'discord.Webhook.from_url', 'discord.Webhook.from_url', (["os.environ['webhook99']"], {'session': 'self.bot.session'}), "(os.environ['webhook99'], session=self.bot.session)\n", (6330, 6381), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((6398, 6474), 'discord.Embed', 'discord.Embed', ([], {'title': '"""Update"""', 'color': '(35056)', 'timestamp': 'ctx.message.created_at'}), "(title='Update', color=35056, timestamp=ctx.message.created_at)\n", (6411, 6474), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((11890, 11911), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (11909, 11911), False, 'import traceback, textwrap\n'), ((12402, 12436), 'importlib.import_module', 'importlib.import_module', ([], {'name': 'args'}), '(name=args)\n', (12425, 12436), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((12547, 12571), 'importlib.reload', 'importlib.reload', (['module'], {}), '(module)\n', (12563, 12571), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((13693, 13740), 'traceback.format_exception', 'traceback.format_exception', (['etype', 'error', 'trace'], {}), '(etype, error, trace)\n', (13719, 13740), False, 'import traceback, textwrap\n'), ((18019, 18040), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (18038, 18040), False, 'import traceback, textwrap\n'), ((761, 788), 'random.randint', 'random.randint', (['(0)', '(16777215)'], {}), '(0, 16777215)\n', (775, 788), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((1604, 1625), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (1623, 1625), False, 'import traceback, textwrap\n'), ((2309, 2330), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (2328, 2330), False, 'import traceback, textwrap\n'), ((2612, 2633), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (2631, 2633), False, 'import traceback, textwrap\n'), ((4542, 4569), 'random.randint', 'random.randint', (['(0)', '(16777215)'], {}), '(0, 16777215)\n', (4556, 4569), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((8750, 8777), 'random.randint', 'random.randint', (['(0)', '(16777215)'], {}), '(0, 16777215)\n', (8764, 8777), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((9588, 9615), 'random.randint', 'random.randint', (['(0)', '(16777215)'], {}), '(0, 16777215)\n', (9602, 9615), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((12474, 12495), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (12493, 12495), False, 'import traceback, textwrap\n'), ((12610, 12631), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (12629, 12631), False, 'import traceback, textwrap\n'), ((15638, 15659), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (15657, 15659), False, 'import traceback, textwrap\n'), ((646, 662), 'utils.check', 'utils.check', (['ctx'], {}), '(ctx)\n', (657, 662), False, 'import utils\n'), ((2070, 2091), 'traceback.print_exc', 'traceback.print_exc', ([], {}), '()\n', (2089, 2091), False, 'import traceback, textwrap\n'), ((7840, 7856), 'utils.check', 'utils.check', (['ctx'], {}), '(ctx)\n', (7851, 7856), False, 'import utils\n'), ((3477, 3540), 'discord.Activity', 'discord.Activity', ([], {'type': 'discord.ActivityType.watching', 'name': 'args'}), '(type=discord.ActivityType.watching, name=args)\n', (3493, 3540), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((19692, 19742), 'discord.utils.format_dt', 'discord.utils.format_dt', (['g.me.joined_at'], {'style': '"""d"""'}), "(g.me.joined_at, style='d')\n", (19715, 19742), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n'), ((19747, 19797), 'discord.utils.format_dt', 'discord.utils.format_dt', (['g.me.joined_at'], {'style': '"""T"""'}), "(g.me.joined_at, style='T')\n", (19770, 19797), False, 'import random, discord, os, importlib, mystbin, typing, aioimgur, functools, tweepy\n')]