Esempio n. 1
0
 async def source(self, ctx, *, command: str = None):
     # This command was mostly ripped from R-Danny (but not all of it.)
     # This is allowed under mozilla license.
     url = "https://github.com/Compass-Bot-Team/Compass"
     branch = "rewrite"
     if command is None:
         return await ctx.send(embed=embeds.twoembed("My source!", url))
     if command == 'help':
         src = type(self.bot.help_command)
         module = src.__module__
         filename = inspect.getsourcefile(src)
     else:
         async with ctx.channel.typing():
             obj = self.bot.get_command(command.replace('.', ' '))
             if obj is None:
                 return await ctx.send(
                     embed=embeds.twoembed("My source!", url))
             src = obj.callback.__code__
             module = obj.callback.__module__
             filename = src.co_filename
         lines, firstlineno = inspect.getsourcelines(src)
         if not module.startswith('discord'):
             location = os.path.relpath(filename).replace('\\', '/')
         else:
             location = module.replace('.', '/') + '.py'
         await ctx.send(embed=embeds.twoembed(
             f"Source for {command}!",
             f'{url}/blob/{branch}/{location}#L{firstlineno}-L{firstlineno + len(lines) - 1}'
         ))
Esempio n. 2
0
 async def bot(self, ctx, bot: typing.Union[discord.Member, discord.User]):
     if bot.bot:
         if bot in ctx.guild.members:
             embed = embeds.twoembed(
                 f"Information about {bot}!",
                 f"You can invite {bot} by [clicking here.](https://discord.com/api/oauth2/authorize?client_id={bot.id}&permissions={bot.guild_permissions.value}&scope=bot)"
             )
             embed.add_field(
                 name="Bot Permissions",
                 value=
                 f"[{bot.guild_permissions.value}](https://discordapi.com/permissions.html#{bot.guild_permissions.value})",
                 inline=True)
         else:
             embed = embeds.twoembed(
                 f"Information about {bot}!",
                 f"You can invite {bot} by [clicking here.](https://discord.com/api/oauth2/authorize?client_id={bot.id}&permissions=8&scope=bot)"
             )
         embed.set_thumbnail(url=bot.avatar_url)
         async with aiosqlite.connect('storage.db') as db:
             server = await db.execute(
                 f"""SELECT server FROM SupportServers WHERE bot = "{bot.id}";"""
             )
             grabbed_server = str(await server.fetchone()).replace(
                 "('", "").replace(")", "").replace("%27,",
                                                    "").replace("',", "")
             embed.add_field(
                 name="Support Server",
                 value=grabbed_server.replace(
                     "None",
                     "None (request a support server by joining [here.](https://discord.gg/SymdusT))"
                 ),
                 inline=True)
         await ctx.send(embed=embed)
     else:
         raise commands.BadArgument("This isn't a bot!")
Esempio n. 3
0
 async def support(self, ctx, *, question: str):
     support_channel = self.bot.get_channel(support_channel_id)
     embed = embeds.twoembed(f"Question from {ctx.author}!", question)
     embed.add_field(name="Channel ID", value=ctx.channel.id, inline=True)
     embed.add_field(name="Author ID", value=ctx.author.id, inline=True)
     await support_channel.send(embed=embed)
     await ctx.send(embed=embeds.twoembed(
         "Sent to the support team!",
         "Join the support server at [this link.](https://discord.gg/SymdusT)"
     ))
Esempio n. 4
0
 async def rockpaperscissors(self, ctx):
     timeoutbed = embeds.twoembed("Timed out.", "you spent too long lol")
     await ctx.send(embed=embeds.twoembed(
         "Rock Paper Scissors menu", "**1** - Play against the AI.\n"
         "~~**2** - Play against another person.~~ non-existent for now"))
     try:
         moment = await self.bot.wait_for(
             'message',
             timeout=180,
             check=lambda msg:
             (msg.author.id == ctx.author.id and msg.channel == ctx.channel)
         )
     except asyncio.TimeoutError:
         await ctx.send(embed=timeoutbed)
         return
     else:
         if moment.content.lower()[0] == '1':
             ai_move = random.choice(["Rock", "Paper", "Scissors"])
             await ctx.send(embed=embeds.twoembed(
                 "I've cast my move! Now you cast yours.", "**1** - Rock\n"
                 "**2** - Paper\n"
                 "**3** - Scissors"))
             try:
                 bruh_moment = await self.bot.wait_for(
                     'message',
                     timeout=180,
                     check=lambda msg: (msg.author.id == ctx.author.id and
                                        msg.channel == ctx.channel))
             except asyncio.TimeoutError:
                 await ctx.send(embed=timeoutbed)
                 return
             else:
                 human_move = str(bruh_moment.content.lower()[0]).replace(
                     "1", "Rock").replace("2",
                                          "Paper").replace("3", "Scissors")
                 if f"{ai_move} {human_move}" in [
                         "Rock Paper", "Paper Scissors", "Scissors Rock"
                 ]:
                     status = "you won!"
                 if f"{ai_move} {human_move}" in [
                         "Paper Rock", "Scissors Paper", "Rock Scissors"
                 ]:
                     status = "you lost."
                 if f"{ai_move} {human_move}" in [
                         "Rock Rock", "Paper Paper", "Scissors Scissors"
                 ]:
                     status = "there was a draw, oops."
                 await ctx.send(embed=embeds.twoembed(
                     f"{ctx.author}, {status}",
                     f"The AI played: {ai_move}\n"
                     f"You played: {human_move}"))
Esempio n. 5
0
 async def ping(self, ctx):
     start = time.perf_counter()
     message = await ctx.send(
         embed=embeds.twoembed("Pinging...", "Sit tight!"))
     end = time.perf_counter()
     embed = embeds.twoembed("Pong!",
                             str(round((end - start) * 1000)) + "ms")
     embed.add_field(name="Websocket",
                     value=str(round(self.bot.latency * 1000)) + "ms",
                     inline=True)
     embed.add_field(name="SQL Database",
                     value=await self.db_speed(),
                     inline=True)
     await message.edit(embed=embed)
Esempio n. 6
0
 async def disconnect(self, ctx):
     player = self.bot.wavelink.get_player(ctx.guild.id)
     if not player.is_connected:
         return await ctx.send(embed=embeds.failembed(
             "Compass isn't connected!", "You gotta connect it. bro."))
     members = len(ctx.author.voice.channel.members)
     if ctx.author.guild_permissions.move_members or members < 3:
         await player.disconnect()
         await ctx.send(embed=embeds.twoembed(
             f"Disconnected from {ctx.author.voice.channel}!", "Cya."))
     else:
         return await ctx.send(embed=embeds.twoembed(
             "Couldn't leave a voice channel.",
             "You need perms (or you need to be the only one in VC!)"))
Esempio n. 7
0
 async def urban(self, ctx, *, term: str):
     headers = {
         "x-rapidapi-key": self.bot.config["urbankey"],
         "x-rapidapi-host":
         "mashape-community-urban-dictionary.p.rapidapi.com"
     }
     async with ctx.channel.typing():
         async with aiohttp.ClientSession(headers=headers) as session:
             async with session.get(
                     "https://mashape-community-urban-dictionary.p.rapidapi.com/define",
                     params={"term": term}) as thing:
                 response = await thing.json()
     definition = response["list"][0]
     embed = embeds.twoembed(
         f"Definition for {term} on Urban Dictionary!",
         definition["definition"].replace(r"\n", "\n").replace(r"\r", "\n"))
     embed.add_field(name="Example",
                     value=definition["example"].replace(r"\n",
                                                         "\n").replace(
                                                             r"\r", "\n"),
                     inline=True)
     embed.set_footer(
         text=
         f":thumbsup: {definition['thumbs_up']} | {definition['thumbs_down']} :thumbsdown:"
     )
     await ctx.send(embed=embed)
Esempio n. 8
0
 async def avatar(self, ctx, user: discord.User = None):
     if user is None:
         user = ctx.message.author
     embed = embeds.twoembed(f"{user}'s avatar!",
                             f"[URL]({user.avatar_url})")
     embed.set_image(url=f"{user.avatar_url}")
     await ctx.send(embed=embed)
Esempio n. 9
0
 async def say(self, ctx, *,
               content: commands.clean_content(use_nicknames=False,
                                               fix_channel_mentions=True)):
     embed = embeds.twoembed(f"Message from {ctx.author}!",
                             discord.utils.escape_mentions(content))
     embed.set_thumbnail(url=ctx.author.avatar_url)
     await ctx.send(embed=embed)
Esempio n. 10
0
 async def discordstatus(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "https://srhpyqt94yxb.statuspage.io/api/v2/incidents.json"
         ) as page:
             json = await page.json()
     incident = json['incidents'][0]
     embed = embeds.twoembed(incident['name'] + " | " + incident['impact'],
                             incident['incident_updates'][0]['body'],
                             timestamp=False)
     embed.url = incident['shortlink']
     embed.add_field(name="Created At",
                     value=incident['created_at'].replace("T", " "),
                     inline=True)
     if 'monitoring_at' in incident:
         embed.add_field(name="Monitoring At",
                         value=incident['monitoring_at'].replace("T", " "),
                         inline=True)
     if 'resolved_at' in incident:
         embed.add_field(name="Resolved At",
                         value=incident['resolved_at'].replace("T", " "),
                         inline=True)
     embed.add_field(name="ID",
                     value=incident['page_id'].replace("T", " "),
                     inline=True)
     embed.timestamp = datetime.datetime.strptime(
         incident['updated_at'].replace("T", " "), '%Y-%m-%d %H:%M:%S.%f%z')
     await ctx.send(embed=embed)
Esempio n. 11
0
    async def about(self, ctx):
        DTOG = self.bot.get_user(self.bot.config["owners"][0])
        Anto = self.bot.get_user(210473676339019776)
        LegitSi = self.bot.get_user(184145857526890506)
        embed = embeds.twoembed(
            f"About", f"Owner: {DTOG} {DTOG.id}\n"
            f"Bot Artist: {Anto} {Anto.id}\n"
            f"Hurricane Man: {LegitSi} {LegitSi.id}\n"
            f"Uptime: {await useful_functions.uptime(self.bot)}\n")
        embed.url = "https://www.github.com/Compass-Bot-Team/Compass"
        embed.set_thumbnail(
            url=
            "https://raw.githubusercontent.com/Compass-Bot-Team/Compass/main/github.png"
        )
        embed.add_field(name="Top Bot Users",
                        value=f"{await useful_functions.users(self.bot)}",
                        inline=True)
        embed.add_field(
            name="Top No-Lifers",
            value=f"{await useful_functions.noliferusers(self.bot)}",
            inline=True)
        embed.add_field(name="Top Guild Bot Users",
                        value=f"{await useful_functions.guilds(self.bot)}",
                        inline=False)
        embed.add_field(
            name="Top Guild No-Lifers",
            value=f"{await useful_functions.noliferguilds(self.bot)}",
            inline=False)

        embed.add_field(
            name="Stats",
            value=
            f"Cogs: {len(self.bot.cogs):,} ({await useful_functions.cogs(self.bot)})\n"
            f"Commands: {self.bot.command_num:,}\n"
            f"Messages: {self.bot.message_num:,}\n"
            f"Total Users: {len(self.bot.users):,}\n"
            f"Total Humans: {sum(not m.bot for m in self.bot.users):,}\n"
            f"Servers: {len(self.bot.guilds):,}",
            inline=False)
        embed.add_field(
            name="Operating Stats",
            value=
            f"Memory Usage: {humanize.naturalsize(self.memory.rss)} physical, {humanize.naturalsize(self.memory.vms)} virtual, {humanize.naturalsize(self.memory.uss)} dedicated to the bot\n "
            f"CPU Usage: {round(self.process.cpu_percent() / psutil.cpu_count(), 1)}%\n"
            f"Operating System: {sys.platform}",
            inline=False)
        invite = "https://discord.com/oauth2/authorize?client_id=769308147662979122&permissions=2147352567&scope=bot"
        embed.add_field(
            name="Some Links",
            value=
            f"[Invite]({invite}) | [Support Server](https://discord.gg/SymdusT) | [GitHub](https://www.github.com/Compass-Bot-Team/Compass) | [Website](https://compasswebsite.dev)"
        )
        embed.set_footer(
            text=
            f"Made in discord.py {pkg_resources.get_distribution('discord.py').version} + "
            f"Python {self.version.major}.{self.version.minor}.{self.version.micro}!"
        )
        await ctx.send(embed=embed)
Esempio n. 12
0
 async def guildmessages(self, ctx):
     _dict = self.bot.guild_senders
     if f"{ctx.guild} ({ctx.guild.id})" not in _dict:
         _dict[f"{ctx.guild} ({ctx.guild.id})"] = 0
     guild = f"{ctx.guild} ({ctx.guild.id})"
     embed = embeds.twoembed(f"Current standings for {ctx.guild}!",
                             f"""{_dict[guild]:,} human messages""")
     embed.set_thumbnail(url=ctx.guild.icon_url)
     await ctx.send(embed=embed)
Esempio n. 13
0
 async def send_command_help(self, command):
     channel = self.get_destination()
     async with channel.typing():
         title = self.get_command_signature(command)
         if command.signature:
             title += f" {command.signature}"
         embed = embeds.twoembed(f"``{title}``", command.help)
         embed.url = await source(command.qualified_name)
     await channel.send(embed=embed)
Esempio n. 14
0
 async def on_message_delete(self, message):
     if message.author.bot:
         return
     else:
         embed = embeds.twoembed(f"Message from {message.author} deleted!",
                                 message.content)
         embed.timestamp = datetime.datetime.utcnow()
         embed.set_thumbnail(url=message.author.avatar_url)
         self.bot.snipe[message.channel.id] = embed
         return embed
Esempio n. 15
0
 async def on_message_edit(self, before, after):
     if before.author.bot:
         return
     else:
         embed = embeds.twoembed(f"Message edited by {before.author}!",
                                 before.content)
         embed.timestamp = datetime.datetime.utcnow()
         embed.set_thumbnail(url=before.author.avatar_url)
         self.bot.editsnipe[before.channel.id] = embed
         return embed
Esempio n. 16
0
 async def google(self, ctx, *, arg):
     results = await self.engine.search(f"{arg}")
     if results[0].snippet is not None:
         snippet = str(results[0].snippet)
     else:
         snippet = "No snippet available."
     embed = embeds.twoembed(results[0].title, snippet)
     embed.add_field(name="URL", value=results[0].link, inline=True)
     embed.set_image(url=f"{results[0].image}")
     await ctx.send(embed=embed)
Esempio n. 17
0
 async def reddit(self, ctx):
     memes = []
     subreddit = await self.reddit.subreddit("dankmemes")
     async for submission in subreddit.hot(limit=20):
         memes.append(submission)
     meme = random.choice(memes)
     embed = embeds.twoembed(f"{meme.title}", f"{meme.score} upvotes")
     embed.url = f"http://reddit.com/r/dankmemes/comments/{meme.id}"
     embed.set_image(url=meme.url)
     await ctx.send(embed=embed)
Esempio n. 18
0
 async def connect(self, ctx):
     player = self.bot.wavelink.get_player(ctx.guild.id)
     try:
         await player.connect(ctx.author.voice.channel.id)
         await ctx.send(embed=embeds.twoembed(
             f"Connected to {ctx.author.voice.channel}!", "Helo."))
     except Exception:
         await ctx.send(
             embed=embeds.failembed("Couldn't connect to a voice channel.",
                                    "Try joining a voice channel."))
Esempio n. 19
0
 async def chat(self, ctx, *,
                content: commands.clean_content(use_nicknames=False,
                                                fix_channel_mentions=True)):
     if len(content) < 3 or len(content) > 60:
         await ctx.send(embed=embeds.failembed(
             "All messages must be above 3 and below 60 characters!",
             "API limitations, sowwy."))
     else:
         chatbot = await self.cleverbot.ask(
             discord.utils.escape_mentions(str(content)))
         await ctx.send(embed=embeds.twoembed(f"Response!", chatbot))
Esempio n. 20
0
 async def reload(self, ctx, *, extension: str):
     alls = ["all", "All"]
     if extension in alls:
         for cog in self.bot.cogs_tuple:
             self.bot.reload_extension(cog)
             useful_functions.logger.info(f"Loaded cog {cog}")
         return await ctx.send(
             embed=embeds.twoembed(f"Success!", f"Reloaded every cog."))
     elif ", " in extension:
         extensions = extension.split(", ")
         for cog in extensions:
             self.bot.reload_extension(str("cogs." + cog))
             useful_functions.logger.info(f"Reloaded cog {cog}")
         return await ctx.send(embed=embeds.twoembed(
             f"Success!", f"Reloaded cogs.{extension}."))
     else:
         self.bot.reload_extension(str("cogs." + extension))
         useful_functions.logger.info(f"Reloaded cog cogs.{extension}")
         await ctx.send(embed=embeds.twoembed(
             f"Success!", f"Reloaded cogs.{extension}."))
Esempio n. 21
0
 async def trump(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 'https://api.tronalddump.io/random/quote') as r:
             res = await r.json()
         embed = embeds.twoembed("Your Trump quote!", res['value'])
         embed.set_thumbnail(
             url=
             "https://cdn.discordapp.com/attachments/777248921205866546/797288910282948608/kUuht00m.png"
         )
         await ctx.send(embed=embed)
Esempio n. 22
0
 async def statuses(self, ctx):
     status_list = ""
     async with aiosqlite.connect("storage.db") as db:
         async with db.execute("SELECT *, rowid FROM Statuses;") as cursor:
             while True:
                 try:
                     for _ in iter(int, 1):
                         info = await cursor.fetchone()
                         status_list += f"• {info[0]} (ID #{info[1]})\n"
                 except Exception:
                     break
     await ctx.send(embed=embeds.twoembed("All statuses!", status_list))
Esempio n. 23
0
 async def on_message(self, message):
     if not message.guild or message.guild.id != support_server_id or message.author.bot or message.webhook_id is not None\
             or message.channel.id != chatbot_channel_id:
         return
     elif len(message.content) < 3 or len(message.content) > 60:
         await message.channel.send(embed=embeds.failembed(
             "All messages must be above 3 and below 60 characters!",
             "API limitations, sowwy."))
     else:
         await message.channel.send(embed=embeds.twoembed(
             f"Cleverbot's response!", await self.cleverbot.ask(
                 str(message.content))))
Esempio n. 24
0
 async def taylor(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 f"https://api.taylor.rest") as taylorquoteraw:
             taylorquoteget = await taylorquoteraw.json()
         async with session.get(
                 f"https://api.taylor.rest/image") as imageraw:
             imagegrab = await imageraw.json()
     embed = embeds.twoembed("Your Taylor Swift quote!",
                             taylorquoteget['quote'])
     embed.set_thumbnail(url=imagegrab['url'])
     await ctx.send(embed=embed)
Esempio n. 25
0
 async def on_message_edit(self, before, after):
     if not before.guild or before.guild.id != support_server_id:
         return
     if before.author.bot:
         return
     embed = embeds.twoembed(f"Message edited in #{before.channel}!",
                             before.content)
     embed.add_field(name="Message Author",
                     value=f"<@!{before.author.id}>",
                     inline=True)
     embed.set_thumbnail(url=f"{before.author.avatar_url}")
     logchannel = self.bot.get_channel(log_channel_id)
     await logchannel.send(embed=embed)
Esempio n. 26
0
 async def quote(self, ctx, id: int = None):
     if id is not None:
         query = f"SELECT *, rowid FROM Quotes WHERE rowid = {id};"
     else:
         query = "SELECT *, rowid FROM Quotes ORDER BY RANDOM() LIMIT 1;"
     async with aiosqlite.connect("storage.db") as db:
         async with db.execute(query) as cursor:
             get_info = await cursor.fetchone()
             rowid = get_info[2]
             author = get_info[1]
             quote = get_info[0]
             await ctx.send(
                 embed=embeds.twoembed(f"Quote {rowid}", f"> {quote}\n"
                                       f"  - <@{author}>"))
Esempio n. 27
0
 async def space(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 f"https://api.nasa.gov/planetary/apod?api_key={self.bot.config['nasakey']}"
         ) as nasa_raw:
             nasa_json = await nasa_raw.json()
         embed = embeds.twoembed(nasa_json['title'],
                                 nasa_json['explanation'])
         if 'copyright' in nasa_json:
             embed.add_field(name="Copyright",
                             value=nasa_json['copyright'],
                             inline=True)
         embed.set_image(url=nasa_json['hdurl'])
         await ctx.send(embed=embed)
Esempio n. 28
0
 async def iss(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://api.open-notify.org/iss-now") as raw:
             iss_info = await raw.json()
     embed = embeds.twoembed("Location of the International Space Station!",
                             "Up, up and away.")
     embed.add_field(name="Longitude",
                     value=iss_info['iss_position']['longitude'],
                     inline=True)
     embed.add_field(name="Latitude",
                     value=iss_info['iss_position']['latitude'],
                     inline=True)
     await ctx.send(embed=embed)
Esempio n. 29
0
 async def weather(self, ctx, *, city: str):
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 f"http://api.openweathermap.org/data/2.5/weather?appid={self.bot.config['weatherapikey']}&q={city}"
         ) as r:
             x = await r.json()
     if x["cod"] != "404":
         embed = embeds.twoembed(
             f"{city}'s weather!",
             f"{str(x['weather'][0]['description'])}\n"
             f"Humidity: {x['main']['humidity']}\n"
             f"Temperature (Celsius): {str(round(x['main']['temp'] - 273.15))}\n"
             f"Temperature (Fahrenheit): {str(round((round(x['main']['temp'] - 273.15) * 9 / 5) + 32))}\n "
             f"Pressure: {x['main']['pressure']}\n")
         await ctx.send(embed=embed)
     else:
         raise commands.BadArgument(f"{city} doesn't exist!")
Esempio n. 30
0
 async def play(self, ctx, *, song):
     tracks = await self.bot.wavelink.get_tracks(f'ytsearch:{song}')
     if not tracks:
         return await ctx.send(embed=embeds.failembed(
             f'Could not find any songs. {self.bot.get_emoji(799142599927005184)}',
             f'Try something else, I have no brain power sowwy.'))
     player = self.bot.wavelink.get_player(ctx.guild.id)
     if not player.is_connected:
         await ctx.invoke(self.connect)
     emoji = self.bot.get_emoji(799142822842335262)
     embed = embeds.twoembed(
         f'Added {str(tracks[0])} to the queue {emoji}',
         f'[URL](https://www.youtube.com/watch?v={tracks[0].ytid})\n'
         f'The length of this is {await self.length(tracks[0].length)}.')
     embed.set_thumbnail(url=tracks[0].thumb)
     await ctx.send(embed=embed)
     await player.play(tracks[0])