Skip to content
Open
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
2 changes: 1 addition & 1 deletion dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

async def setup(bot: Red):
cog = Dashboard(bot)
bot.add_cog(cog)
await bot.add_cog(cog)
await cog.initialize()
7 changes: 6 additions & 1 deletion dashboard/abc/abc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod

from redbot.core import Config
from redbot.core import Config, commands
from redbot.core.bot import Red


Expand All @@ -12,3 +12,8 @@ class MixinMeta(ABC):
def __init__(self, *_args):
self.config: Config
self.bot: Red

@commands.group(name="dashboard")
async def dashboard(self, ctx: commands.Context):
"""Group command for controlling the web dashboard for Red."""
pass
Comment on lines +16 to +19
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is because the old method of importing the top level command object caused an unexpected CTX to be required for all commands preventing Red's autohelp from functioning and all commands for that matter. This method maintains the expected behavior of one top level command shared between all files.

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.baserpc import HUMANIZED_PERMISSIONS

dashboard = MixinMeta.dashboard


class DashboardRolesMixin(MixinMeta):
@checks.guildowner()
Expand Down
3 changes: 2 additions & 1 deletion dashboard/abc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import os

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

from dashboard.baserpc import HUMANIZED_PERMISSIONS

dashboard = MixinMeta.dashboard

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


Expand Down
4 changes: 3 additions & 1 deletion dashboard/abc/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import discord

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

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


dashboard = MixinMeta.dashboard


class DashboardWebserverMixin(MixinMeta):
@checks.is_owner()
@dashboard.group()
Expand Down
25 changes: 8 additions & 17 deletions dashboard/baserpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def get_variables(self):

returning = {
"botname": self.bot.user.name,
"botavatar": str(self.bot.user.avatar_url_as(static_format="png")),
"botavatar": str(self.bot.user.avatar.url),
"botid": self.bot.user.id,
"clientid": client_id,
"botinfo": markdown2.markdown(botinfo),
Expand Down Expand Up @@ -261,9 +261,9 @@ async def get_users_servers(self, userid: int):
"name": escape(guild.name),
"id": str(guild.id),
"owner": escape(str(guild.owner)),
"icon": str(guild.icon_url_as(format="png"))[:-13]
or "https://cdn.discordapp.com/embed/avatars/1.",
"animated": guild.is_icon_animated(),
"icon": str(guild.icon.url)[:-13] if guild.icon else
"https://cdn.discordapp.com/embed/avatars/1.",
"animated": guild.icon.is_animated() if guild.icon else False,
"go": False,
}
if is_owner:
Expand Down Expand Up @@ -351,15 +351,6 @@ async def get_server(self, userid: int, serverid: int):
else:
vl = "Unknown"

region = getattr(guild.region, "name", guild.region)
parts = region.split("_")
for i, p in enumerate(parts):
if p in ["eu", "us", "vip"]:
parts[i] = p.upper()
else:
parts[i] = p.title()
region = " ".join(parts)

Comment on lines -354 to -362
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Region is no longer part of the guild object. Maybe replace region with the servers locale?

if not self.cog.configcache.get(serverid, {"roles": []})["roles"]:
warn = True
else:
Expand All @@ -386,9 +377,9 @@ async def get_server(self, userid: int, serverid: int):
"name": escape(guild.name),
"id": guild.id,
"owner": escape(str(guild.owner)),
"icon": str(guild.icon_url_as(format="png"))[:-13]
or "https://cdn.discordapp.com/embed/avatars/1.",
"animated": guild.is_icon_animated(),
"icon": str(guild.icon.url)[:-13] if guild.icon else
"https://cdn.discordapp.com/embed/avatars/1.",
"animated": guild.icon.is_animated() if guild.icon else False,
"members": humanize_number(len(guild.members)),
"online": humanize_number(stats["o"]),
"idle": humanize_number(stats["i"]),
Expand All @@ -402,7 +393,7 @@ async def get_server(self, userid: int, serverid: int):
"joined": joined,
"roleswarn": warn,
"vl": vl,
"region": region,
"region": "",
"prefixes": await self.bot.get_valid_prefixes(guild),
"adminroles": adminroles,
"modroles": modroles,
Expand Down
1 change: 0 additions & 1 deletion dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Dashboard(
DashboardRolesMixin,
DashboardWebserverMixin,
DashboardSettingsMixin,
DBMixin,
commands.Cog,
metaclass=CompositeMetaClass,
):
Expand Down