add auto-publish

This commit is contained in:
mudkipdev
2023-09-20 19:12:22 -06:00
parent db662539ea
commit f91debeb90
3 changed files with 17 additions and 0 deletions

View File

@@ -7,7 +7,9 @@ extensions = [
"extensions.announcements",
"extensions.templates"
]
repost_channels = []
publish_channels = []
[permissions]
# This works in a whitelist mode. The invoker of the command must be in an allowed guild and

View File

@@ -45,6 +45,17 @@ class CoreCog(commands.Cog, name="Core"):
async def on_ready(self) -> None:
print("The bot is now ready.")
@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
if (
message.channel.id in self.bot.config.publish_channels
and message.channel.type is discord.ChannelType.news
):
try:
await message.publish()
except discord.Forbidden:
pass
@commands.hybrid_command(description="Shows you some info about the bot.")
async def info(self, ctx: commands.Context) -> None:
embed = discord.Embed(

View File

@@ -25,6 +25,10 @@ class Config:
def repost_channels(self) -> list[int]:
return self.config["bot"].get("repost_channels", [])
@property
def publish_channels(self) -> list[int]:
return self.config["bot"].get("publish_channels", [])
@property
def allowed_guilds(self) -> list:
return self._get_allowed_objects("allowed_guilds")