diff --git a/README.md b/README.md index 73734da..d4b838b 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,18 @@ Robobert: https://github.com/JTexpo/Robobert ![specific comic](https://github.com/BBArikL/BDBot/blob/assets/comic-demo-3.png) - Subscribe to a comic +There are 2 ways to set up scheduled comics: + - Latest: Get only the latest comics when they are posted, no need to set up an exact day of the week or an hour of the day. + - Regular: Get the comic at a regular day and hour of the week. A date should be one of the seven days of the week and the hour a number representing the time in a 24h clock in UTC time (0h to 23h). If not specified, defaults to the current time in UTC. + ![comic subscription](https://github.com/BBArikL/BDBot/blob/assets/comic-demo-4.png) + + ## Current state of the project - Functionalities - - `/` Information embed on the requested comic. - - `/help` : Help embed + - `/` Use comic + - `/help general` : Help embed - `/git` command : Redirects to this GitHub page - `/invite` command : Generate a link to invite the bot to your server ([or use this link](https://discord.com/api/oauth2/authorize?client_id=807780409362481163&permissions=0&scope=bot)) - Daily Command: use `/ add/remove` to add or remove a comic from the daily list for the server. diff --git a/bdbot/cogs/BDbot.py b/bdbot/cogs/BDbot.py index 015da65..ff209f8 100644 --- a/bdbot/cogs/BDbot.py +++ b/bdbot/cogs/BDbot.py @@ -3,7 +3,7 @@ import os import re from datetime import datetime, timezone -from typing import Union +from typing import Optional, Union import discord import topgg @@ -110,6 +110,25 @@ async def on_shard_disconnect(self, shard_id: int): f"Shard of id {shard_id} has been disconnected. Retrying to reconnect..." ) + @commands.Cog.listener() + async def on_guild_join(self, guild: discord.Guild): + message_channel: Optional[discord.TextChannel] = None + channels = guild.text_channels + + for channel in channels: + if channel.permissions_for( + guild.get_member(self.bot.user.id) + ).send_messages: + message_channel = channel + break + + if message_channel is not None: + await message_channel.send( + "Thanks for choosing BDBot! Use `/help general` for a list of commands and" + " comics available and `/help schedule` to know how to set up your server to" + " receive comics automatically!" + ) + @app_commands.command() async def git(self, inter: discord.Interaction): """GitHub page""" diff --git a/bdbot/cogs/HelpCommands.py b/bdbot/cogs/HelpCommands.py index 18ac04e..11d249e 100644 --- a/bdbot/cogs/HelpCommands.py +++ b/bdbot/cogs/HelpCommands.py @@ -7,6 +7,7 @@ class HelpCommands(commands.Cog): """Class responsible for sending help embeds""" + help_group = app_commands.Group(name="help", description="Help commands") def __init__(self, bot: commands.Bot): @@ -17,7 +18,7 @@ def __init__(self, bot: commands.Bot): @help_group.command() async def general(self, inter: discord.Interaction): - """HelpCommands for BDBot""" + """Help commands for BDBot""" embed: discord.Embed if discord_utils.HELP_EMBED is None: strips = utils.strip_details @@ -41,17 +42,15 @@ async def general(self, inter: discord.Interaction): for strip in strips: if ( strips[strip]["Main_website"] != "https://www.gocomics.com/" - and strips[strip]["Main_website"] - != "https://comicskingdom.com/" - and strips[strip]["Main_website"] - != "https://www.webtoons.com/en/" + and strips[strip]["Main_website"] != "https://comicskingdom.com/" + and strips[strip]["Main_website"] != "https://www.webtoons.com/en/" ): embed.add_field( name=strips[strip]["Name"], value=strips[strip]["Helptxt"] ) embed.add_field( name="Hourly comics commands.", - value="Use /help hourly to see available commands for daily comics. " + value="Use /help schedule to see available commands for daily comics. " "Post daily at 6:00 AM UTC.", ) @@ -102,18 +101,23 @@ async def general(self, inter: discord.Interaction): await discord_utils.send_embed(inter, [embed]) @help_group.command() - async def hourly(self, inter: discord.Interaction): - """HelpCommands for hourly commands""" + async def schedule(self, inter: discord.Interaction): + """Get help to schedule an automatic comic post""" embed: discord.Embed - if discord_utils.HOURLY_EMBED is None: + if discord_utils.SCHEDULE_EMBED is None: embed = discord.Embed( title="Daily commands!", description="Date and hour are optional arguments that can specify when the the " - "bot should send the comic. A date should be one of the seven days " - "of the week and the hour a number representing the time in a 24h " - "clock in UTC time. If not specified, defaults to the current time " + "bot should send the comic. \n" + "There are 2 ways to set up scheduled comics:\n" + "Latest: Get only the latest comics when they are posted, no need to set up an " + "exact day of the week or an hour of the day.\n" + "Regular: Get the comic at a regular day and hour of the week." + " A date should be one of the seven days of the week and the " + "hour a number representing the time in a 24h clock in UTC time" + " (0h to 23h). If not specified, defaults to the current time " "in UTC.", ) embed.add_field( @@ -174,7 +178,7 @@ async def hourly(self, inter: discord.Interaction): utils.HOURLY_EMBED = embed else: - embed = discord_utils.HOURLY_EMBED + embed = discord_utils.SCHEDULE_EMBED await discord_utils.send_embed(inter, [embed]) @@ -320,7 +324,7 @@ async def faq(self, inter: discord.Interaction): ) embed.add_field( name="How can I receive scheduled comics?", - value="You can use `/help hourly` to get help on how to schedule comics.", + value="You can use `/help schedule` to get help on how to schedule comics.", ) embed.add_field( name="What information is collected by using this bot?", diff --git a/bdbot/discord_utils.py b/bdbot/discord_utils.py index 84093e4..1ec4b8e 100644 --- a/bdbot/discord_utils.py +++ b/bdbot/discord_utils.py @@ -36,7 +36,7 @@ SERVER: Optional[discord.Object] = None HELP_EMBED: Optional[discord.Embed] = None -HOURLY_EMBED: Optional[discord.Embed] = None +SCHEDULE_EMBED: Optional[discord.Embed] = None NEW_EMBED: Optional[discord.Embed] = None FAQ_EMBED: Optional[discord.Embed] = None GOCOMICS_EMBED: Optional[list[discord.Embed]] = None @@ -1057,7 +1057,7 @@ async def send_chan_embed(channel: discord.TextChannel, embed: discord.Embed): def get_possible_hours(): - return [app_commands.Choice(name=str(h), value=h) for h in range(1, 25)] + return [app_commands.Choice(name=str(h), value=h) for h in range(0, 24)] def get_possible_days():