Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bot): send changelog on connect #56

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 45 additions & 56 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
commitizen = "^3.7.1"
commitizen = "^3.8.2"
coverage = "^7.2.5"
mypy = "^1.5.0"
pdoc = "^14.0.0"
poethepoet = "^0.21.1"
pre-commit = "^3.3.3"
ruff = "^0.0.287"
sh = "^2.0.6"
shellcheck-py = "^0.9.0.5"
types-aiofiles = "^23.2.0.0"
typos = "^1.16.9"
Expand Down
2 changes: 1 addition & 1 deletion src/valentina/cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from valentina.constants import RollResultType
from valentina.models.bot import Valentina
from valentina.utils import errors
from valentina.utils.helpers import assert_permissions
from valentina.utils.discord_utils import assert_permissions
from valentina.views import (
SettingsManager,
ThumbnailReview,
Expand Down
32 changes: 28 additions & 4 deletions src/valentina/cogs/event_listeners.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Respond to events that occur in the Discord server."""

import random

import discord
from discord.ext import commands
from loguru import logger

from valentina.constants import BAD_WORD_LIST
from valentina.constants import BAD_WORD_LIST, BOT_DESCRIPTIONS, EmbedColor
from valentina.models.bot import Valentina
from valentina.models.db_tables import Guild
from valentina.models.errors import reporter
from valentina.utils.bot_hooks import respond_to_mentions


class Events(commands.Cog, name="Events"):
Expand All @@ -17,6 +18,7 @@ class Events(commands.Cog, name="Events"):
def __init__(self, bot: Valentina) -> None:
self.bot: Valentina = bot

@commands.Cog.listener()
@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
"""on_message event handling."""
Expand All @@ -31,8 +33,23 @@ async def on_message(self, message: discord.Message) -> None:

# Respond to @mentions of the bot
if self.bot.user.mentioned_in(message) and message.mention_everyone is False:
await respond_to_mentions(self.bot, message)
return
description = [
"### Hi there!",
f"**I'm Valentina Noir, a {random.choice(BOT_DESCRIPTIONS)}.**\n",
"I'm still in development, so please be patient with me.\n",
"There are a few ways to get help using me. (_You do want to use me, right?_)\n",
"- Type `/help` to get a list of commands",
"- Type `/help <command>` to get help for a specific command",
"- Type `/help user_guide` to read about my capabilities",
"- Type `/changelog` to read about my most recent updates\n",
" If none of those answered your questions, please contact an admin.",
]

embed = discord.Embed(
title="", description="\n".join(description), color=EmbedColor.INFO.value
)
embed.set_thumbnail(url=self.bot.user.display_avatar)
await message.channel.send(embed=embed)

if any(word in message.content.lower() for word in BAD_WORD_LIST):
await message.channel.send("You kiss your mother with that mouth?")
Expand Down Expand Up @@ -67,6 +84,13 @@ async def on_member_join(self, member: discord.Member) -> None:
# Add user to the database
self.bot.user_svc.fetch_user(user=member)

@commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild) -> None:
"""Called when the bot joins a guild."""
logger.info(f"EVENT: Joined {guild.name} ({guild.id})")

await self.bot.guild_svc.prepare_guild(guild=guild)


def setup(bot: Valentina) -> None:
"""Add the cog to the bot."""
Expand Down
Loading