mirror of
https://github.com/hencaric/SCNewsBot.git
synced 2026-08-17 06:56:03 +01:00
add auto-publish
This commit is contained in:
@@ -7,7 +7,9 @@ extensions = [
|
|||||||
"extensions.announcements",
|
"extensions.announcements",
|
||||||
"extensions.templates"
|
"extensions.templates"
|
||||||
]
|
]
|
||||||
|
|
||||||
repost_channels = []
|
repost_channels = []
|
||||||
|
publish_channels = []
|
||||||
|
|
||||||
[permissions]
|
[permissions]
|
||||||
# This works in a whitelist mode. The invoker of the command must be in an allowed guild and
|
# This works in a whitelist mode. The invoker of the command must be in an allowed guild and
|
||||||
|
|||||||
@@ -45,6 +45,17 @@ class CoreCog(commands.Cog, name="Core"):
|
|||||||
async def on_ready(self) -> None:
|
async def on_ready(self) -> None:
|
||||||
print("The bot is now ready.")
|
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.")
|
@commands.hybrid_command(description="Shows you some info about the bot.")
|
||||||
async def info(self, ctx: commands.Context) -> None:
|
async def info(self, ctx: commands.Context) -> None:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ class Config:
|
|||||||
def repost_channels(self) -> list[int]:
|
def repost_channels(self) -> list[int]:
|
||||||
return self.config["bot"].get("repost_channels", [])
|
return self.config["bot"].get("repost_channels", [])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def publish_channels(self) -> list[int]:
|
||||||
|
return self.config["bot"].get("publish_channels", [])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def allowed_guilds(self) -> list:
|
def allowed_guilds(self) -> list:
|
||||||
return self._get_allowed_objects("allowed_guilds")
|
return self._get_allowed_objects("allowed_guilds")
|
||||||
|
|||||||
Reference in New Issue
Block a user