Skip to content

Getting mafic working in a cog #57

Answered by Kraots
xFGhoul asked this question in Q&A
Discussion options

You must be logged in to vote
    @staticmethod
    async def get_player(ctxContext-> mafic.Player: 
         if not ctx.guild.voice_client: 
             player = await ctx.author.voice.channel.connect(cls=mafic.Player) 
         else: 
             player = ctx.guild.voice_client 
  
         return player

You can use this, basically what it does is it first checks if there's no player for the guild the command was invoked in, and if there isn't it creates one, otherwise it returns the already existing player object for that guild

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xFGhoul
Comment options

Answer selected by ooliver1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants