I have this Discord.py Cog
object that contains a bunch of methods that I would like to split into multiple files to browse easier. (most stuff cut out for brevity)
class VoteManager(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.group(pass_context=True, invoke_without_command=True)
async def vote(self, ctx):
await ctx.send(f'Command not found. Use `{BOT_CALL_PREFIX}vote help` for commands.')
def new(self, channel_id):
pass # Actual logic for new_command, separated so it could be called without context
@vote.command(name='new')
async def new_command(self):
pass # Really long function, etc.
What I want is to be able to split definitions like new
and new_command
into their own file new.py
.
The VoteManager
class is in the __init__.py
file of discordbot.voting
module. So when used, I use bot.add_cog(discordbot.voting.VoteManager(bot))
to add it to the registry of commands for the bot.
The goal is to be able to just do something like from .voting.new import *
in the VoteManager
class and have it read the functions to be added.