Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import inspect

from redbot.core.bot import Red

from .dashboard import Dashboard


async def setup(bot: Red):
cog = Dashboard(bot)
bot.add_cog(cog)
if inspect.iscoroutinefunction(bot.add_cog):
await bot.add_cog(cog)
else:
bot.add_cog(cog)
await cog.initialize()
11 changes: 4 additions & 7 deletions dashboard/abc/mixin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from redbot.core import commands


@commands.group(name="dashboard")
async def dashboard(self, ctx: commands.Context):
"""Group command for controlling the web dashboard for Red."""
pass


class DBMixin:
""" This is mostly here to easily mess with things... """

c = dashboard
@commands.group(name="dashboard")
async def dashboard(self, ctx: commands.Context):
"""Group command for controlling the web dashboard for Red."""
pass
3 changes: 2 additions & 1 deletion dashboard/abc/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import discord

from dashboard.abc.abc import MixinMeta
from dashboard.abc.mixin import dashboard
from dashboard.abc.mixin import DBMixin

from dashboard.baserpc import HUMANIZED_PERMISSIONS

dashboard = DBMixin.dashboard

class DashboardRolesMixin(MixinMeta):
@checks.guildowner()
Expand Down
93 changes: 14 additions & 79 deletions dashboard/abc/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from redbot.core import commands, checks
from redbot.core.utils.chat_formatting import box, humanize_list, inline
from redbot import __version__ as red_version
from typing import Optional
import discord
import platform
import socket
Expand All @@ -10,12 +9,13 @@
import os

from dashboard.abc.abc import MixinMeta
from dashboard.abc.mixin import dashboard
from dashboard.abc.mixin import DBMixin

from dashboard.baserpc import HUMANIZED_PERMISSIONS

THEME_COLORS = ["red", "primary", "blue", "green", "greener", "yellow"]

dashboard = DBMixin.dashboard

class DashboardSettingsMixin(MixinMeta):
@checks.is_owner()
Expand Down Expand Up @@ -186,97 +186,32 @@ async def color_settings(self, ctx, color: str):
"""Set the default color for a new user.

The webserver version must be at least 0.1.3a.dev in order for this to work."""
color = color.lower()
if color == "purple":
color = "primary"
if color not in THEME_COLORS:
return await ctx.send(
"Unrecognized color. Please choose one of the following:\n"
f"{humanize_list(tuple(map(lambda x: inline(x).title(), THEME_COLORS)))}"
)
await self.config.defaultcolor.set(color)
await ctx.tick()
return await ctx.send(
"This command has been migrated to the webserver in the admin panel."
)

@settings.command()
async def support(self, ctx: commands.Context, url: str = ""):
"""Set the URL for support. This is recommended to be a Discord Invite.

Leaving it blank will remove it.
"""
await self.config.support.set(url)
await ctx.tick()
return await ctx.send(
"This command has been migrated to the webserver in the admin panel."
)

@settings.group()
@settings.command()
async def meta(self, ctx: commands.Context):
"""Control meta tags that are rendered by a service.

For example, Discord rendering a link with an embed"""
pass

@meta.command()
async def title(self, ctx, *, title: str = ""):
"""Set the meta title tag for the rendered UI from link.

For Discord, this is the larger text hyperlinked to the url.

The following arguments will be replaced if they are in the title:
{name} | The bot's username"""
await self.config.meta.title.set(title)
if not title:
return await ctx.send("Meta title reset to default.")
await ctx.tick()

@meta.command()
async def icon(self, ctx, link: Optional[str] = ""):
"""Set the meta icon tag for the rendered UI from link.

For Discord, this is the large icon in the top right of the embed."""
await self.config.meta.icon.set(link)
if not link:
return await ctx.send("Meta icon reset to default.")
await ctx.tick()

@meta.command()
async def description(self, ctx, *, description: str = ""):
"""Set the meta description tag for the rendered UI from link.

For Discord, this is the smaller text under the title.

The following arguments will be replaced if they are in the title:
{name} | The bot's username"""
await self.config.meta.description.set(description)
if not description:
return await ctx.send("Meta description reset to default.")
await ctx.tick()

@meta.command(name="color")
async def color_meta(self, ctx, *, color: discord.Colour = ""):
"""Set the meta color tag for the rendered UI from link.

For Discord, this is the colored bar that appears in the left of the embed."""
await self.config.meta.color.set(str(color))
if not color:
return await ctx.send("Meta color reset to default.")
await ctx.tick()
return await ctx.send(
"This command has been migrated to the webserver in the admin panel."
)

@settings.command()
async def view(self, ctx: commands.Context):
"""View the current dashboard settings."""
data = await self.config.all()
redirect = data["redirect"]
secret = data["secret"]
support = data["support"]
color = data["defaultcolor"]
if not support:
support = "[Not set]"
description = (
f"Client Secret: | {secret}\n"
f"Redirect URI: | {redirect}\n"
f"Support Server: | {support}\n"
f"Default theme: | {color}"
return await ctx.send(
"This command has been migrated to the webserver in the admin panel."
)
embed = discord.Embed(title="Red V3 Dashboard Settings", color=0x0000FF)
embed.description = box(description, lang="ini")
embed.add_field(name="Dashboard Version", value=box(f"[{self.__version__}]", lang="ini"))
embed.set_footer(text="Dashboard created by Neuro Assassin.")
await ctx.author.send(embed=embed)
3 changes: 2 additions & 1 deletion dashboard/abc/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import discord

from dashboard.abc.abc import MixinMeta
from dashboard.abc.mixin import dashboard
from dashboard.abc.mixin import DBMixin

from dashboard.baserpc import HUMANIZED_PERMISSIONS
from dashboard.menus import ClientList, ClientMenu

dashboard = DBMixin.dashboard

class DashboardWebserverMixin(MixinMeta):
@checks.is_owner()
Expand Down
Loading