Skip to main content

A python module to access and utilize Beta Discord VC Party features like YouTube, Poker Night, etc. with your Bot

Project description

DCActivity

An unofficial module used to access Discord's Beta features like YouTube, Poker Night, etc. by your Bot


Installation

  • Python 3.8 or higher is required
  • discord.py V1.5.0 or higher is required

To install the library, simply run the following command in your terminal:

# Windows
py -m pip install dcactivity

# Linux/macOS
python3 -m pip install dcactivity

Usage

To use the library, you must first import it into your script and create a new instance of the DCActivity class:

from discord.ext import commands
from dcactivity import DCActivity

bot = commands.Bot(command_prefix='!')
bot.dcact = DCActivity(bot)

To create the invite link, you need to use create_link() function:

link = await bot.dcact.create_link(voice_channel, app_id)
  • voice_channel: The Voice channel you want to create the invite link for. Can be Channel ID or discord.VoiceChannel object

  • app_id: The Application ID of the Voice Channel game. For this, you need to follow either of the three steps:

    • Import DCApplication from dcactivity:

      from dcactivity import DCApplication
      
      link = await bot.dcact.create_link(voice_channel, DCApplication.youtube) # or DCApplication.poker, etc.
      
    • Directly use Application Name or ID (use ID only if you know the exact ID of an activity):

      link = await bot.dcact.create_link(voice_channel, 'youtube') # or poker, chess, etc.
      

Examples

Bot:

# bot.py

from discord import VoiceChannel
from discord.ext import commands
from dcactivity import DCActivity, DCApplication

bot = commands.Bot(command_prefix='!')
dcactivity = DCActivity(bot) # or "bot.dcactivity = DCActivity(bot)" to use it as a BotVar

@bot.command()
async def youtube(ctx, channel: VoiceChannel):
    link = await dcactivity.get_link(channel, DCApplication.youtube)
    await ctx.send(link)

bot.run('token')

Bot with Cogs:

  • bot:

    # bot.py
    
    from discord import VoiceChannel
    from discord.ext import commands
    from dcactivity import DCActivity
    
    bot = commands.Bot(command_prefix='!')
    bot.dcactivity = DCActivity(bot)
    
    bot.load_extension('cogs.cog') # Simple Example with Cog
    bot.load_extension('cogs.cog_advanced') # Advanced Example with Cog
    
    bot.run('token')
    
  • cog (simple):

    # cog.py
    
    from discord import VoiceChannel
    from discord.ext import commands
    from dcactivity import DCApplication
    
    
    class MyCog(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
        
        @commands.command()
        async def youtube(self, ctx, channel: VoiceChannel):
            link = await self.bot.dcactivity.get_link(channel, DCApplication.youtube)
            await ctx.send(link)
    
    def setup(bot):
        bot.add_cog(MyCog(bot))
    
  • cog (advanced):

    # cog_advanced.py
    
    from typing import Optional
    from discord import VoiceChannel
    from discord.ext import commands
    from dcactivity import DCApplication
    from dcactivity.errors import InvalidChannel
    
    
    class MyAdvancedCog(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
    
        @commands.command()
        async def custom_link(self, ctx, channel=None):
            if not channel:
                if not ctx.author.voice:
                    return await ctx.send('You need to connect to a voice channel first')
                if not isinstance(ctx.author.voice.channel, VoiceChannel):
                    return await ctx.send('This feature is not supported in Stage Channels.')
                _channel = ctx.author.voice.channel
            else:
                _channel = channel
            
            link = await self.bot.dcactivity.get_link(
                ctx.author.voice.channel, DCApplication.youtube, max_age=0, max_uses=10)
            await ctx.send(link)
    
        @custom_link.error
        async def custom_link_error(self, ctx, exc):
            exc = getattr(exc, 'original', exc)
            if isinstance(exc, InvalidChannel):
                await ctx.send('Invalid Channel given as argument.')
    
    def setup(bot):
        bot.add_cog(MyAdvancedCog(bot))
    

Note

  • A minimum of one person needs to click on the invite link to start the Voice Channel Activity.
  • Activity resets when everyone exits. Though it can again be joined from the same link but from the starting and not resuming.
  • Games like chess/betrayal may not work in Stable Client for now. To use them, you need install Discord PTB or Discord Canary Client or use them in the web browser.

Info

This package is licensed under MIT License. Any contributions are welcomed.

Need to contribute? Just Open a Pull Request with your changes and some information about your changes.

Found a bug or having an issue? Open an Issue at Github!


Links

Github: https://github.com/AkshuAgarwal/DCActivity

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcactivity-1.0.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

dcactivity-1.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file dcactivity-1.0.0.tar.gz.

File metadata

  • Download URL: dcactivity-1.0.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for dcactivity-1.0.0.tar.gz
Algorithm Hash digest
SHA256 af4a0bee856c9b29618a99d90a6583885f184fe87d3615ff1fd8b627b5bf46a7
MD5 f517d0cfef522d2081e1b1939453af26
BLAKE2b-256 f0d8149bd829f99837de6ba67d1126e7e74ec5d607127801bc53a6ec0d572612

See more details on using hashes here.

File details

Details for the file dcactivity-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dcactivity-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for dcactivity-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46199d799201c928bee2f35857760cd5c06e7f3b4a5e582eb738e5df600d3b1c
MD5 1207874ac08a97ebd3e7018ce123b7bf
BLAKE2b-256 7b450fb58cb3feb3976f58c29b1680da14e99a848cec9933b0795724032233f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page