mirror of
https://github.com/hencaric/SCNewsBot.git
synced 2026-08-16 22:46:03 +01:00
permission changes (breaking changes!!)
This commit is contained in:
@@ -8,14 +8,14 @@ extensions = [
|
||||
"extensions.templates"
|
||||
]
|
||||
|
||||
[permissions]
|
||||
[permissions.announcements]
|
||||
# This works in a whitelist mode. The invoker of the command must be in an allowed guild and
|
||||
# must have an allowed role. If neither of those are true, allowed_users is checked last.
|
||||
allowed_guilds = []
|
||||
allowed_roles = []
|
||||
allowed_users = []
|
||||
|
||||
[permissions.debug]
|
||||
[permissions.announcements.debug]
|
||||
# This works in addition to the regular permissions, but only if debug mode is enabled.
|
||||
allowed_guilds = []
|
||||
allowed_roles = []
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
from extensions.announcements import Announcement
|
||||
from utils import can_publish_announcements
|
||||
|
||||
TEMPLATES: dict[str, Announcement] = {
|
||||
"isc": Announcement(title="Inside Star Citizen | [topic] - [subtopic]"),
|
||||
@@ -58,11 +59,13 @@ class TemplatesCog(commands.Cog, name="Templates"):
|
||||
async def templates(self, ctx: commands.Context) -> None:
|
||||
await ctx.send_help(ctx.command)
|
||||
|
||||
@commands.check(can_publish_announcements)
|
||||
@templates.command(name="list")
|
||||
async def _list(self, ctx: commands.Context) -> None:
|
||||
templates = "\n".join([f"- {template}" for template in self.templates])
|
||||
await ctx.reply(f"Here are all of the available templates: ```\n{templates}```")
|
||||
|
||||
@commands.check(can_publish_announcements)
|
||||
@templates.command()
|
||||
async def view(self, ctx: commands.Context, *, template_name: str) -> None:
|
||||
templates = {name.lower(): value for name, value in self.templates.items()}
|
||||
@@ -78,6 +81,7 @@ class TemplatesCog(commands.Cog, name="Templates"):
|
||||
embed.remove_author()
|
||||
await ctx.reply(embed=embed)
|
||||
|
||||
@commands.check(can_publish_announcements)
|
||||
@commands.command(brief='A shortcut to the "templates view" command.')
|
||||
async def template(self, ctx: commands.Context, *, template_name: str) -> None:
|
||||
await ctx.invoke(
|
||||
@@ -85,6 +89,7 @@ class TemplatesCog(commands.Cog, name="Templates"):
|
||||
template_name=template_name,
|
||||
)
|
||||
|
||||
@commands.check(can_publish_announcements)
|
||||
@commands.command(name="previews", brief="Shows all the possible ping previews.")
|
||||
async def ping_previews(self, ctx: commands.Context) -> None:
|
||||
await ctx.reply(
|
||||
@@ -94,6 +99,7 @@ class TemplatesCog(commands.Cog, name="Templates"):
|
||||
allowed_mentions=discord.AllowedMentions.none(),
|
||||
)
|
||||
|
||||
@commands.check(can_publish_announcements)
|
||||
@commands.command(brief="Shows all the channel IDs for announcements.")
|
||||
async def channels(self, ctx: commands.Context) -> None:
|
||||
await ctx.reply(
|
||||
|
||||
@@ -34,9 +34,9 @@ class Config:
|
||||
return self._get_allowed_objects("allowed_users")
|
||||
|
||||
def _get_allowed_objects(self, object_name, /) -> list:
|
||||
allowed_objects = self.config["permissions"].get(object_name, [])
|
||||
allowed_objects = self.config["permissions"]["announcements"].get(object_name, [])
|
||||
if self.debug:
|
||||
allowed_objects += self.config["permissions"]["debug"].get(object_name, [])
|
||||
allowed_objects += self.config["permissions"]["announcements"]["debug"].get(object_name, [])
|
||||
|
||||
return allowed_objects
|
||||
|
||||
|
||||
Reference in New Issue
Block a user