mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-06 22:34:30 +01:00
Refactor code structure
This commit is contained in:
1 parent
7d99fea020
commit
09844d8292
42 files changed
+70
-65
No files matched your search
@@ -13,20 +13,20 @@ import aiohttp
|
||||
import yaml
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.utils.localisation import Aliaser, LocalizedContext, Localizer, LocalizerWrapper
|
||||
from cogs.utils.logger import BotLogger
|
||||
from cogs.utils.settingsmanager import Settings
|
||||
from musicbot.utils.localisation import Aliaser, LocalizedContext, Localizer, LocalizerWrapper
|
||||
from musicbot.utils.logger import BotLogger
|
||||
from musicbot.utils.settingsmanager import Settings
|
||||
|
||||
initial_extensions = [
|
||||
'cogs.errors',
|
||||
'cogs.cogmanager',
|
||||
'cogs.settings',
|
||||
'cogs.misc',
|
||||
'cogs.helpformatter'
|
||||
'musicbot.cogs.errors',
|
||||
'musicbot.cogs.cogmanager',
|
||||
'musicbot.cogs.settings',
|
||||
'musicbot.cogs.misc',
|
||||
'musicbot.cogs.helpformatter'
|
||||
]
|
||||
|
||||
on_ready_extensions = [
|
||||
'cogs.nodemanager'
|
||||
'musicbot.cogs.nodemanager'
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ from discord.ext import commands
|
||||
import traceback
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.helpformatter import commandhelper
|
||||
from cogs.utils.userinteraction import Scroller
|
||||
from .helpformatter import commandhelper
|
||||
from ..utils.userinteraction import Scroller
|
||||
|
||||
|
||||
class CogManager(commands.Cog):
|
||||
@@ -4,11 +4,11 @@ from discord.ext import commands
|
||||
|
||||
import traceback
|
||||
|
||||
from cogs.music.music_errors import WrongTextChannelError, WrongVoiceChannelError
|
||||
from .music.music_errors import WrongTextChannelError, WrongVoiceChannelError
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.helpformatter import commandhelper
|
||||
from cogs.utils.userinteraction import Scroller
|
||||
from .helpformatter import commandhelper
|
||||
from ..utils.userinteraction import Scroller
|
||||
|
||||
|
||||
class Errors(commands.Cog):
|
||||
@@ -0,0 +1,8 @@
|
||||
from .help import Help
|
||||
from .helpformatter import commandhelper
|
||||
|
||||
__all__ = ['Help', 'commandHelper']
|
||||
|
||||
def setup(bot):
|
||||
bot.remove_command("help")
|
||||
bot.add_cog(Help(bot))
|
||||
@@ -0,0 +1,32 @@
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class Help(commands.Cog):
|
||||
"""Help command"""
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(hidden=True)
|
||||
async def help(self, ctx): # Takes no args because reasons(using the view directly)
|
||||
ctx.view.skip_ws()
|
||||
v = ctx.view
|
||||
invoker = v.buffer[v.index:v.end]
|
||||
ctx = self.bot.aliaser.get_subcommand(ctx, group=None, parents=[])
|
||||
command = v.buffer[v.index:v.end]
|
||||
|
||||
ctx = prefix_cleaner(ctx)
|
||||
|
||||
if not command:
|
||||
paginator = await helper(ctx)
|
||||
|
||||
if command:
|
||||
thing = ctx.bot.get_cog(command) or ctx.bot.get_command(command)
|
||||
if not thing:
|
||||
return await ctx.send(ctx.localizer.format_str("{notcommand}", _command=command))
|
||||
if isinstance(thing, commands.Command):
|
||||
paginator = commandhelper(ctx, thing, invoker)
|
||||
else:
|
||||
paginator = await coghelper(ctx, thing)
|
||||
|
||||
scroller = Scroller(ctx, paginator)
|
||||
await scroller.start_scrolling()
|
||||
@@ -4,7 +4,7 @@ from discord.ext import commands
|
||||
import re
|
||||
|
||||
# Bot Utilities
|
||||
from .utils.userinteraction import HelpPaginator, Scroller
|
||||
from ...utils.userinteraction import HelpPaginator, Scroller
|
||||
|
||||
usermention = r"<@!?\d{17,19}>"
|
||||
|
||||
@@ -111,38 +111,3 @@ def prefix_cleaner(ctx):
|
||||
ctx.prefix = pref
|
||||
return ctx
|
||||
|
||||
|
||||
class Help(commands.Cog):
|
||||
"""Help command"""
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(hidden=True)
|
||||
async def help(self, ctx): # Takes no args because reasons(using the view directly)
|
||||
ctx.view.skip_ws()
|
||||
v = ctx.view
|
||||
invoker = v.buffer[v.index:v.end]
|
||||
ctx = self.bot.aliaser.get_subcommand(ctx, group=None, parents=[])
|
||||
command = v.buffer[v.index:v.end]
|
||||
|
||||
ctx = prefix_cleaner(ctx)
|
||||
|
||||
if not command:
|
||||
paginator = await helper(ctx)
|
||||
|
||||
if command:
|
||||
thing = ctx.bot.get_cog(command) or ctx.bot.get_command(command)
|
||||
if not thing:
|
||||
return await ctx.send(ctx.localizer.format_str("{notcommand}", _command=command))
|
||||
if isinstance(thing, commands.Command):
|
||||
paginator = commandhelper(ctx, thing, invoker)
|
||||
else:
|
||||
paginator = await coghelper(ctx, thing)
|
||||
|
||||
scroller = Scroller(ctx, paginator)
|
||||
await scroller.start_scrolling()
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.remove_command("help")
|
||||
bot.add_cog(Help(bot))
|
||||
@@ -7,7 +7,7 @@ import platform
|
||||
import time
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.utils import bot_version
|
||||
from ..utils import bot_version
|
||||
|
||||
|
||||
class Misc(commands.Cog):
|
||||
@@ -3,7 +3,7 @@ import discord
|
||||
import lavalink
|
||||
from discord.ext import commands
|
||||
|
||||
from ..utils import thumbnailer, timeformatter
|
||||
from ...utils import thumbnailer, timeformatter
|
||||
from .music_errors import WrongTextChannelError
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ from discord.ext import commands
|
||||
import asyncio
|
||||
import re
|
||||
|
||||
from ..utils import checks, timeformatter
|
||||
from ..utils.userinteraction import QueuePaginator, Scroller, Selector
|
||||
from ...utils import checks, timeformatter
|
||||
from ...utils.userinteraction import QueuePaginator, Scroller, Selector
|
||||
from .decorators import require_playing, require_queue, require_voice_connection, voteable
|
||||
|
||||
time_rx = re.compile('[0-9]+')
|
||||
@@ -7,9 +7,9 @@ import functools
|
||||
import inspect
|
||||
import math
|
||||
|
||||
from cogs.music.music_errors import WrongVoiceChannelError
|
||||
from .music_errors import WrongVoiceChannelError
|
||||
|
||||
from ..utils.checks import is_dj
|
||||
from ...utils.checks import is_dj
|
||||
|
||||
|
||||
def require_voice_connection(should_connect=False):
|
||||
File renamed without changes.
@@ -14,8 +14,8 @@ import urllib
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from ..utils import checks
|
||||
from ..utils.userinteraction import Scroller, TextPaginator
|
||||
from ...utils import checks
|
||||
from ...utils.userinteraction import Scroller, TextPaginator
|
||||
from .decorators import require_playing, require_voice_connection, voteable
|
||||
|
||||
|
||||
File renamed without changes.
@@ -8,9 +8,9 @@ import codecs
|
||||
import yaml
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.helpformatter import commandhelper
|
||||
from cogs.utils.userinteraction import Scroller
|
||||
from .utils.mixplayer import MixPlayer
|
||||
from .helpformatter import commandhelper
|
||||
from ..utils.userinteraction import Scroller
|
||||
from ..utils.mixplayer import MixPlayer
|
||||
|
||||
|
||||
class NodeManager(commands.Cog):
|
||||
@@ -20,7 +20,7 @@ class NodeManager(commands.Cog):
|
||||
self.logger = self.bot.main_logger.bot_logger.getChild("NodeManager")
|
||||
|
||||
music_extensions = [
|
||||
'cogs.music',
|
||||
'musicbot.cogs.music',
|
||||
]
|
||||
|
||||
if not hasattr(bot, 'lavalink'):
|
||||
@@ -3,9 +3,9 @@ import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# Bot Utilities
|
||||
from cogs.helpformatter import commandhelper
|
||||
from cogs.utils import checks
|
||||
from cogs.utils.userinteraction import Scroller
|
||||
from .helpformatter import commandhelper
|
||||
from ..utils import checks
|
||||
from ..utils.userinteraction import Scroller
|
||||
|
||||
|
||||
class Settings(commands.Cog):
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user