async def on_message(self, msg): if not self.is_ready() or msg.author.bot or not permissions.can_handle( msg, "send_messages"): return if self.is_ready( ) and not msg.author.bot or not permissions.can_handle( msg, "send_messages"): await self.process_commands(msg)
async def noticeme(self, ctx): """ Notice me senpai! owo """ if not permissions.can_handle(ctx, "attach_files"): return await ctx.send("I cannot send images here ;-;") bio = BytesIO(await http.get("https://i.alexflipnote.dev/500ce4.gif", res_method="read")) await ctx.send(file=discord.File(bio, filename="noticeme.gif"))
async def colour(self, ctx, colour: str): """ View the colour HEX details """ async with ctx.channel.typing(): if not permissions.can_handle(ctx, "embed_links"): return await ctx.send("I can't embed in this channel ;-;") if colour == "random": colour = "%06x" % random.randint(0, 0xFFFFFF) if colour[:1] == "#": colour = colour[1:] if not re.search(r'^(?:[0-9a-fA-F]{3}){1,2}$', colour): return await ctx.send("You're only allowed to enter HEX (0-9 & A-F)") try: r = await http.get( f"https://api.alexflipnote.dev/colour/{colour}", res_method="json", no_cache=True, headers={"Authorization": self.alex_api_token} ) except aiohttp.ClientConnectorError: return await ctx.send("The API seems to be down...") except aiohttp.ContentTypeError: return await ctx.send("The API returned an error or didn't return JSON...") embed = discord.Embed(colour=r["int"]) embed.set_thumbnail(url=r["image"]) embed.set_image(url=r["image_gradient"]) embed.add_field(name="HEX", value=r['hex'], inline=True) embed.add_field(name="RGB", value=r['rgb'], inline=True) embed.add_field(name="Int", value=r['int'], inline=True) embed.add_field(name="Brightness", value=r['brightness'], inline=True) await ctx.send(embed=embed, content=f"{ctx.invoked_with.title()} name: **{r['name']}**")
async def send_pages(self, no_pm: bool = False): try: if permissions.can_handle(self.context, "add_reactions"): await self.context.message.add_reaction(chr(0x2709)) except discord.Forbidden: pass try: destination = self.get_destination(no_pm=no_pm) for page in self.paginator.pages: await destination.send(page) except discord.Forbidden: destination = self.get_destination(no_pm=True) await destination.send( "Couldn't send help to you due to blocked DMs...")
async def botserver(self, ctx): """ Get an invite to our support server! """ async def get_inv(): guild = self.bot.get_guild(config.INVITE[0]) channel = guild.get_channel(config.INVITE[1]) return await channel.create_invite( max_age=300, max_uses=1, reason="botserver") try: if isinstance(ctx.channel, discord.DMChannel): inv = await get_inv() await ctx.author.send(f"Here you go, **{ctx.author}**!\n{inv}") else: if ctx.guild.id == config.INVITE[0]: await ctx.send(f"**{ctx.author.name}**, this is my home you know") else: inv = await get_inv() await ctx.author.send(f"Here you go, **{ctx.author}**!\n{inv}") if permissions.can_handle(ctx, "add_reactions"): await ctx.message.add_reaction(chr(0x2709)) else: await ctx.send("Check ur dm's") except AttributeError as e: await ctx.send(f"Where did I come from!?!") raise e