async def cog_before_invoke(self, ctx): # We don't need to ensure extra for the following commands: if ctx.command.name in ("playingin","autodeleteafter","disableplay"): return # General checks for all music player commands - with specifics filtered per command # If Youtube ratelimits - you can disable music globally so only owners can use it player = self.bot.wavelink.get_player(ctx.guild.id) delay = self.settings.getServerStat(ctx.guild, "MusicDeleteDelay", 20) if self.settings.getGlobalStat("DisableMusic",False) and not Utils.is_owner(ctx): # Music is off - and we're not an owner - disconnect if connected, then send the bad news :( self.dict_pop(ctx) if player.is_connected: await player.destroy() await Message.EmbedText(title="♫ Music player is currently disabled!",color=ctx.author,delete_after=delay).send(ctx) raise commands.CommandError("Music Cog: Music disabled.") # Music is enabled - let's make sure we have the right role if not await self._check_role(ctx): raise commands.CommandError("Music Cog: Missing DJ roles.") # If we're just using the join command - we don't need extra checks - they're done in the command itself if ctx.command.name == "join": return # We've got the role - let's join the author's channel if we're playing/shuffling and not connected if ctx.command.name in ("play","shuffle") and not player.is_connected and ctx.author.voice: await player.connect(ctx.author.voice.channel.id) # Let's ensure the bot is connected to voice if not player.is_connected: await Message.EmbedText(title="♫ Not connected to a voice channel!",color=ctx.author,delete_after=delay).send(ctx) raise commands.CommandError("Music Cog: Not connected to a voice channel.") # Let's make sure the caller is connected to voice and the same channel as the bot - or a bot-admin if Utils.is_bot_admin(ctx): return # We good - have enough perms to override whatever if not ctx.author.voice or not ctx.author.voice.channel.id == int(player.channel_id): await Message.EmbedText(title="♫ You have to be in the same voice channel as me to use that!",color=ctx.author,delete_after=delay).send(ctx) raise commands.CommandError("Music Cog: Author not connected to the bot's voice channel.")
async def embed(self, ctx, *, embed=None): """Build embed menggunakan format json. Types: field text ---------------------------------- Limits (All - owner only): title_max (256) desc_max (2048) field_max (25) fname_max (256) fval_max (1024) foot_max (2048) auth_max (256) total_max (6000) ---------------------------------- Options (All): pm_after (int - fields, or pages) pm_react (str) title (str) page_count (bool) url (str) description (str) image (str) footer (str or dict { text, icon_url }) thumbnail (str) author (str, dict, or User/Member) color (user/member) ---------------------------------- Options (field only): fields (list of dicts { name (str), value (str), inline (bool) }) ---------------------------------- Options (text only): desc_head (str) desc_foot (str) max_pages (int) """ if embed == None: em = discord.Embed( color=0XFF8C00, description="Build embed menggunakan json.\n" "**Panduan penggunaan**\n" "`{}embed [type] [embed json]`\n\n" "*Ketik `{}help embed` untuk melihat informasi lebih lanjut*". format(ctx.prefix, ctx.prefix)) em.set_footer( text="Saat mengetik command, tanda [] tidak usah digunakan\n{}" .format(ctx.author), icon_url="{}".format(ctx.author.avatar_url)) return await ctx.send(embed=em) embed_type = embed.split()[0].lower() if embed.split()[0].lower() in [ "field", "text" ] else "field" try: embed_dict = json.loads(embed) except Exception as e: return await Message.EmbedText(title="Something went wrong...", description=str(e)).send(ctx) # Only allow owner to modify the limits if not Utils.is_owner(ctx): embed_dict["title_max"] = 256 embed_dict["desc_max"] = 2048 embed_dict["field_max"] = 25 embed_dict["fname_max"] = 256 embed_dict["fval_max"] = 1024 embed_dict["foot_max"] = 2048 embed_dict["auth_max"] = 256 embed_dict["total_max"] = 6000 try: if embed_type.lower() == "field": await Message.Embed(**embed_dict).send(ctx) elif embed_type.lower() == "text": await Message.EmbedText(**embed_dict).send(ctx) else: await Message.EmbedText( title="Something went wrong...", description= "\"{}\" is not one of the available embed types...".format( embed_type)).send(ctx) except Exception as e: try: e = str(e) except: e = "An error occurred :(" await Message.EmbedText(title="Something went wrong...", description=e).send(ctx)
async def embed(self, ctx, *, embed=None): """Builds an embed using json formatting. Types: field text ---------------------------------- Limits (All - owner only): title_max (256) desc_max (2048) field_max (25) fname_max (256) fval_max (1024) foot_max (2048) auth_max (256) total_max (6000) ---------------------------------- Options (All): pm_after (int - fields, or pages) pm_react (str) title (str) page_count (bool) url (str) description (str) image (str) footer (str or dict { text, icon_url }) thumbnail (str) author (str, dict, or User/Member) color (user/member) ---------------------------------- Options (field only): fields (list of dicts { name (str), value (str), inline (bool) }) ---------------------------------- Options (text only): desc_head (str) desc_foot (str) max_pages (int) """ if embed == None: return await ctx.send( "Usage: `{}embed [type] [embed json]`".format(ctx.prefix)) embed_type = embed.split()[0].lower() if embed.split()[0].lower() in [ "field", "text" ] else "field" try: embed_dict = json.loads(embed) except Exception as e: return await Message.EmbedText(title="Something went wrong...", description=str(e)).send(ctx) # Only allow owner to modify the limits if not Utils.is_owner(ctx): embed_dict["title_max"] = 256 embed_dict["desc_max"] = 2048 embed_dict["field_max"] = 25 embed_dict["fname_max"] = 256 embed_dict["fval_max"] = 1024 embed_dict["foot_max"] = 2048 embed_dict["auth_max"] = 256 embed_dict["total_max"] = 6000 try: if embed_type.lower() == "field": await Message.Embed(**embed_dict).send(ctx) elif embed_type.lower() == "text": await Message.EmbedText(**embed_dict).send(ctx) else: await Message.EmbedText( title="Something went wrong...", description= "\"{}\" is not one of the available embed types...".format( embed_type)).send(ctx) except Exception as e: try: e = str(e) except: e = "An error occurred :(" await Message.EmbedText(title="Something went wrong...", description=e).send(ctx)