async def change_volume(self, ctx, *, vol: float): vc = ctx.voice_client if not vc or not vc.is_connected(): embed_nvc = AkagiEmbed(title='Error', description='*I am not currently connected to voice channel!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_nvc.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_nvc.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_nvc) if not 0 < vol < 101: embed_errint = AkagiEmbed(title='Error', description='*Please specify a value between 1 and 100!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errint.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_errint.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_errint) player = self.get_player(ctx) if vc.source: vc.source.volume = vol / 100 player.volume = vol / 100 embed_vol = AkagiEmbed(title='Setted', description=f'*Set the volume to {vol}%!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_vol.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_vol.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_vol)
async def serverinfo(self, ctx): if not ctx.guild: embed_errordm = AkagiEmbed( title='Error', description='*This command can only be used in servers!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errordm.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_errordm.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.author.send(embed=embed_errordm) else: embed = AkagiEmbed(title=f"{ctx.guild.name}", timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed.add_field(name="Server created at", value=f"*{ctx.guild.created_at}*") embed.add_field(name="Server Owner", value=f"*{ctx.guild.owner}*") embed.add_field(name="Server Region", value=f"*{ctx.guild.region}*") embed.add_field(name="Server ID", value=f"*{ctx.guild.id}*") embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed)
async def queue_info(self, ctx): vc = ctx.voice_client if not vc or not vc.is_connected(): embed_qnp = AkagiEmbed(title='Error', description=f'*I am not currently playing anything!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_qnp.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_qnp.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_qnp) player = self.get_player(ctx) if player.queue.empty(): embed_errqueue = AkagiEmbed(title='Error', description=f'*There are currently no more queued songs!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errqueue.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_errqueue.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_errqueue) # Grab up to 5 entries from the queue... upcoming = list(itertools.islice(player.queue._queue, 0, 5)) fmt = '\n'.join(f'*{_["title"]}*' for _ in upcoming) embed_queue = AkagiEmbed(title=f'Upcoming next - {len(upcoming)}', description=fmt, timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_queue.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_queue.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_queue)
async def now_playing_(self, ctx): vc = ctx.voice_client if not vc or not vc.is_connected(): embed_npnp = AkagiEmbed(title='Error', description='*I am not currently playing anything!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_npnp.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_npnp.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_npnp) player = self.get_player(ctx) if not player.current: embed_npnp = AkagiEmbed(title='Error', description='*I am not currently playing anything!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_npnp.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_npnp.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_npnp) try: # Remove our previous now_playing message. await player.np.delete() except discord.HTTPException: pass embed_np = AkagiEmbed(title='Now Playing', description=f'*{vc.source.title} Requested by {vc.soirce.requester}!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_np.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_np.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) player.np = await ctx.send(embed=embed_np)
async def changeprefix_error_handler(self, ctx, error): if isinstance(error, MissingRequiredArgument): if error.param.name == 'prefix': embed_errargs = AkagiEmbed(title='Error', description='*Please specify the new prefix!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errargs.set_footer(text="{}".format(ctx.author.display_name),icon_url=ctx.author.avatar_url) embed_errargs.set_author(name=ctx.me.display_name, icon_url = ctx.me.avatar_url) await ctx.send(embed=embed_errargs)
async def resume_(self, ctx): vc = ctx.voice_client if not vc or not vc.is_connected(): embed_errnp = AkagiEmbed(title='Error', description=f'*I am not currently playing anything!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errnp.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_errnp.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_errnp) elif not vc.is_paused(): return vc.resume() embed_resumed = AkagiEmbed(title='Resumed', description=f'*Song resumed by {ctx.author}!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_resumed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_resumed.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_resumed)
async def stop_(self, ctx): vc = ctx.voice_client if not vc or not vc.is_connected(): embed_snp = AkagiEmbed(title='Error', description='*I am not currently playing anything!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_snp.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_snp.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) return await ctx.send(embed=embed_snp) await self.cleanup(ctx.guild)
async def config(self, ctx): embed_help = AkagiEmbed(title=f'{Rem}Config Commands', description='*changeprefix.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def player_loop(self): await self.bot.wait_until_ready() while not self.bot.is_closed(): self.next.clear() try: # Wait for the next song. If we timeout cancel the player and disconnect... async with timeout(300): # 5 minutes... source = await self.queue.get() except asyncio.TimeoutError: return self.destroy(self._guild) if not isinstance(source, YTDLSource): # Source was probably a stream (not downloaded) # So we should regather to prevent stream expiration try: source = await YTDLSource.regather_stream(source, loop=self.bot.loop) except Exception as e: embed_error = AkagiEmbed(title='Error', description=f'*There was an error processing your song! {e}*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_error.set_author(name=self.bot.user.display_name, icon_url=self.bot.user.avatar_url) await self._channel.send(embed=embed_error) continue source.volume = self.volume self.current = source self._guild.voice_client.play(source, after=lambda _: self.bot.loop.call_soon_threadsafe(self.next.set)) embed_np = AkagiEmbed(title='Now Playing', description=f'*{source.title} Requested by {source.requester}!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_np.set_author(name=self.bot.user.display_name, icon_url=self.bot.user.avatar_url) self.np = await self._channel.send(embed=embed_np) await self.next.wait() # Make sure the FFmpeg process is cleaned up. source.cleanup() self.current = None try: # We are no longer playing this song... await self.np.delete() except discord.HTTPException: pass
async def changeprefix(self, ctx, prefix): if not ctx.guild: embed_errordm = AkagiEmbed(title='Error', description='*This command can only be used in servers!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errordm.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_errordm.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.author.send(embed=embed_errordm) else: with open('AkagiModules/Abstract/Database/Prefixes.json', 'r') as f: Prefixes = json.load(f) Prefixes[str(ctx.guild.id)] = prefix with open('AkagiModules/Abstract/Database/Prefixes.json', 'w') as f: json.dump(Prefixes, f, indent=4) embed_prefixchange = AkagiEmbed(title='Changed', description=f'*Prefix changed to {prefix}*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_prefixchange.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_prefixchange.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_prefixchange)
async def donate(self, ctx): embed_donate = AkagiEmbed( title='Donate!', description=f'*You can support me by being a [Patron]({Patreon})!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_donate.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_donate.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_donate)
async def roleplay(self, ctx): embed_help = AkagiEmbed( title=f'{Mae}Roleplay Commands', description='*cuddle, kiss, hug, feed, pat, poke, smug, tickle.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def images(self, ctx): embed_help = AkagiEmbed( title=f'{CerberusNeko}Images Commands', description='*awwnime, cat, dog, duck, ferret, fox, frog.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def general(self, ctx): embed_help = AkagiEmbed( title=f'{Disappointed}General Commands', description='*donate, help, info, serverinfo, userinfo.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def music(self, ctx): embed_help = AkagiEmbed( title=f'{Comfy}Music Commands', description= '*connect, play, pause, resume, skip, queue, nowplaying, volume, stop.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def ass_error_handler(self, ctx, error): if isinstance(error, commands.NSFWChannelRequired): embed = AkagiEmbed( title=f"Error", description='*This command is Only for NSFW Channels!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) return await ctx.send(embed=embed)
async def on_command_error(ctx, error): if isinstance(error, NoPrivateMessage): embed_errguild = AkagiEmbed( title='Error', description='*This Command is only available on Servers!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errguild.set_footer(text="{}".format( ctx.author.display_name), icon_url=ctx.author.avatar_url) embed_errguild.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) await ctx.send(embed=embed_errguild)
async def on_command_error(ctx, error): if isinstance(error, MissingPermissions): embed_errperms = AkagiEmbed( title='Error', description='*You‘re lack of permissions to use this command!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_errperms.set_footer(text="{}".format( ctx.author.display_name), icon_url=ctx.author.avatar_url) embed_errperms.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) await ctx.send(embed=embed_errperms)
async def connect_(self, ctx, *, channel: discord.VoiceChannel=None): if not channel: try: channel = ctx.author.voice.channel except AttributeError: # await ctx.send(embed=embed_novc) embed_novc = AkagiEmbed(title='Error', description='*No channel to join. Please specify valid one!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_novc.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_novc.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_novc) vc = ctx.voice_client if vc: if vc.channel.id == channel.id: return try: await vc.move_to(channel) except asyncio.TimeoutError: embed_mtm = AkagiEmbed(title='Moving', description=f'*Moving to channel {channel} timed out!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_mtm.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_mtm.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_mtm) else: try: await channel.connect() except asyncio.TimeoutError: embed_cc = AkagiEmbed(title='Connecting', description=f'*Connecting to channel {channel} timed out!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_cc.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_cc.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_cc) embed_ccc = AkagiEmbed(title='Connected', description=f'*Connected to {channel}!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_ccc.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_ccc.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_ccc)
async def nsfw(self, ctx): if not ctx.channel.nsfw: embed_help = AkagiEmbed( title=f'{ChikaPout}Nsfw Commands', description='*Only Available in NSFW Channels!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help) else: embed_help = AkagiEmbed( title=f'{ChikaPout}Nsfw Commands', description= '*ass, boobs, bdsm, bottomless, dick, chubby, collared, hentai, nsfw, kinky, pawg, pussy, redhead.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)
async def on_message(message): await Akagibot.process_commands(message) try: if message.mentions[0] == Akagibot.user: with open("AkagiModules/Abstract/Database/Prefixes.json", "r") as f: Prefixes = json.load(f) pre = Prefixes[str(message.guild.id)] embed=AkagiEmbed(title='Prefix', description=f'*My prefix for this guild is {pre}*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed.set_footer(text="{}".format(message.author.display_name), icon_url=message.author.avatar_url) embed.set_author(name=message.guild.me.display_name, icon_url=message.guild.me.avatar_url) await message.channel.send(embed=embed) except: return
async def fox(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("http://randomfox.ca/floof/") as r: data = await r.json() embed_floof = AkagiEmbed( title='Fox!', description=f'[*Floof~*]({data["image"]})', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_floof.set_image(url=data['image']) embed_floof.set_footer(text="{}".format( ctx.author.display_name), icon_url=ctx.author.avatar_url) embed_floof.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) await ctx.send(embed=embed_floof)
async def cat(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("http://aws.random.cat/meow") as r: data = await r.json() embed_meow = AkagiEmbed( title='Cat!', description=f'[*Meow~*]({data["file"]})', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_meow.set_image(url=data['file']) embed_meow.set_footer(text="{}".format( ctx.author.display_name), icon_url=ctx.author.avatar_url) embed_meow.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) await ctx.send(embed=embed_meow)
async def pat(self, ctx, member: discord.Member = None): if member is None: member = ctx.author async with aiohttp.ClientSession() as cs: async with cs.get("https://nekos.life/api/v2/img/pat") as r: data = await r.json() embed_pat = AkagiEmbed( title='Pat!', description= f'*{ctx.author.display_name} pats {member.display_name}~*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_pat.set_image(url=data['url']) embed_pat.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) embed_pat.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) await ctx.send(embed=embed_pat)
async def info(self, ctx): file = discord.File("AkagiModules/Abstract/Akagi.png", filename="akagi.png") serverCount = len(self.bot.guilds) memberCount = len(set(self.bot.get_all_members())) embed_info = AkagiEmbed( title='Info', description= '*Akagi is one of the main Antagonist of Azur lane the Animation, an aircraft carrier of Sakura.*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_info.set_image(url='attachment://akagi.png') embed_info.add_field(name='Servers', value=f'*{serverCount}*') embed_info.add_field(name='Members', value=f'*{memberCount}*') embed_info.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_info.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(file=file, embed=embed_info)
async def frog(self, ctx): subreddit = reddit.subreddit('frogs') all_subs = [] top = subreddit.top(limit=5) for submission in top: all_subs.append(submission) random_sub = random.choice(all_subs) name = random_sub.title url = random_sub.url embed = AkagiEmbed(title=f"Frog!", description=f'[*{name}*]({url})', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed.set_image(url=url) embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed)
async def create_source(cls, ctx, search: str, *, loop, download=False): loop = loop or asyncio.get_event_loop() to_run = partial(ytdl.extract_info, url=search, download=download) data = await loop.run_in_executor(None, to_run) if 'entries' in data: # take first item from a playlist data = data['entries'][0] embed_added = AkagiEmbed(title='Added', description=f'*Added {data["title"]} to the Queue!*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_added.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_added.set_footer(text="{}".format(ctx.author.display_name), icon_url =ctx.author.avatar_url) await ctx.send(embed=embed_added) if download: source = ytdl.prepare_filename(data) else: return {'webpage_url': data['webpage_url'], 'requester': ctx.author, 'title': data['title']} return cls(discord.FFmpegPCMAudio(source), data=data, requester=ctx.author)
async def help(self, ctx): embed_help = AkagiEmbed( title=f'{AkagiYes}Help', description= f'*{ctx.prefix}help [Command Category] to get the commands!\n[Invite me~]({InviteLink}), [Support me~]({Patreon})*', timestamp=datetime.datetime.utcnow(), color=discord.Color.red()) embed_help.add_field(name=f'{Rem}Config', value=f'*{ctx.prefix}help config*') embed_help.add_field(name=f'{Disappointed}General', value=f'*{ctx.prefix}help general*') embed_help.add_field(name=f'{CerberusNeko}Images', value=f'*{ctx.prefix}help images*') embed_help.add_field(name=f'{Comfy}Music', value=f'*{ctx.prefix}help music*') embed_help.add_field(name=f'{Mae}Roleplay', value=f'*{ctx.prefix}help roleplay*') embed_help.add_field(name=f'{ChikaPout}Nsfw', value=f'*{ctx.prefix}help nsfw*') embed_help.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) embed_help.set_footer(text="{}".format(ctx.author.display_name), icon_url=ctx.author.avatar_url) await ctx.send(embed=embed_help)