Skip to content

Commit

Permalink
Merge pull request #29
Browse files Browse the repository at this point in the history
v4.5.3
  • Loading branch information
BBArikL authored Nov 15, 2022
2 parents 41c8d39 + ccbeded commit 1e4e12c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- `/<comic_name>` Information embed on the requested comic.
- `/help` : Help embed
- `/<comic_name>` Use comic <comic_name>
- `/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 `/<name_of_comic> add/remove` to add or remove a comic from the daily list for the server.
Expand Down
21 changes: 20 additions & 1 deletion bdbot/cogs/BDbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down
32 changes: 18 additions & 14 deletions bdbot/cogs/HelpCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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.",
)

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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?",
Expand Down
4 changes: 2 additions & 2 deletions bdbot/discord_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 1e4e12c

Please sign in to comment.