mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 16:23:12 +00:00
Optimize code
This commit is contained in:
parent
c27ba95c14
commit
72e48cea63
35 changed files with 914 additions and 912 deletions
15
.github/workflows/docker-image.yml
vendored
15
.github/workflows/docker-image.yml
vendored
|
@ -17,8 +17,7 @@ jobs:
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Docker meta
|
||||||
name: Docker meta
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
|
@ -31,25 +30,21 @@ jobs:
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
-
|
- name: Set up Docker Buildx
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
- name: Login to Docker Hub
|
||||||
name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
- name: Login to GHCR
|
||||||
name: Login to GHCR
|
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
- name: Build and push
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|
|
@ -16,7 +16,7 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
# Run the linter.
|
# Run the linter.
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix]
|
args: [ --fix ]
|
||||||
# Run the formatter.
|
# Run the formatter.
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
|
||||||
### 4. Permanent Ban
|
### 4. Permanent Ban
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Contributing to Luminara
|
# Contributing to Luminara
|
||||||
|
|
||||||
Thank you for your interest in contributing to Lumi! We welcome contributions from the community to help improve and expand the bot's functionality. Please follow these guidelines when contributing:
|
Thank you for your interest in contributing to Lumi! We welcome contributions from the community to help improve and
|
||||||
|
expand the bot's functionality. Please follow these guidelines when contributing:
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
@ -10,35 +11,39 @@ Thank you for your interest in contributing to Lumi! We welcome contributions fr
|
||||||
|
|
||||||
3. **Set Up Development Environment:**
|
3. **Set Up Development Environment:**
|
||||||
|
|
||||||
* **Docker:** To run the bot, use this command to run your newly edited code:
|
* **Docker:** To run the bot, use this command to run your newly edited code:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose -f docker-compose.dev.yml up --build
|
docker compose -f docker-compose.dev.yml up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Poetry:** While developing, it is recommended to install & configure poetry locally:
|
* **Poetry:** While developing, it is recommended to install & configure poetry locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
poetry install
|
poetry install
|
||||||
poetry shell
|
poetry shell
|
||||||
poetry pre-commit install
|
poetry pre-commit install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Making Changes
|
## Making Changes
|
||||||
|
|
||||||
1. **Create a Branch:** Create a new branch for your changes.
|
1. **Create a Branch:** Create a new branch for your changes.
|
||||||
2. **Code Style:** Adhere to the existing code style and formatting conventions.
|
2. **Code Style:** Adhere to the existing code style and formatting conventions.
|
||||||
3. **Strict Typing:** Always use strict typing (e.g., `str`, `int`, `List[str]`) for better code quality and maintainability.
|
3. **Strict Typing:** Always use strict typing (e.g., `str`, `int`, `List[str]`) for better code quality and
|
||||||
4. **Pre-Commit Checks:** Before committing, run pre-commit checks to ensure your code passes linting and formatting standards.
|
maintainability.
|
||||||
|
4. **Pre-Commit Checks:** Before committing, run pre-commit checks to ensure your code passes linting and formatting
|
||||||
|
standards.
|
||||||
5. **Clear Commit Messages:** Write clear and concise commit messages that describe the changes you made.
|
5. **Clear Commit Messages:** Write clear and concise commit messages that describe the changes you made.
|
||||||
|
|
||||||
## Submitting Changes
|
## Submitting Changes
|
||||||
|
|
||||||
1. **Create a Pull Request:** Create a pull request (PR) from your branch to the `main` branch of the original repository.
|
1. **Create a Pull Request:** Create a pull request (PR) from your branch to the `main` branch of the original
|
||||||
|
repository.
|
||||||
2. **Review:** Your PR will be reviewed by the Sourcery & Lumi maintainers. Address any feedback or requested changes.
|
2. **Review:** Your PR will be reviewed by the Sourcery & Lumi maintainers. Address any feedback or requested changes.
|
||||||
3. **Merge:** Once approved, your PR will be merged into the main branch.
|
3. **Merge:** Once approved, your PR will be merged into the main branch.
|
||||||
|
|
||||||
## Additional Notes
|
## Additional Notes
|
||||||
|
|
||||||
* **Documentation:** If you add new functionality or change existing behavior, update or add the docstrings accordingly.
|
* **Documentation:** If you add new functionality or change existing behavior, update or add the docstrings accordingly.
|
||||||
|
|
||||||
Thank you for your contributions!
|
Thank you for your contributions!
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
|
|
||||||
![Lumi art](https://git.wlinator.org/assets/img/logo.png)
|
![Lumi art](https://git.wlinator.org/assets/img/logo.png)
|
||||||
|
|
||||||
|
|
||||||
## Self-Hosting
|
## Self-Hosting
|
||||||
|
|
||||||
Self-hosting refers to running Luminara on your own server or computer, rather than using the publicly hosted version. This approach offers the ability to manage your own instance of the bot and give it a custom name and avatar.
|
Self-hosting refers to running Luminara on your own server or computer, rather than using the publicly hosted version.
|
||||||
|
This approach offers the ability to manage your own instance of the bot and give it a custom name and avatar.
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
Before you begin, make sure you have the following installed on your system:
|
Before you begin, make sure you have the following installed on your system:
|
||||||
|
|
||||||
- [Docker](https://docs.docker.com/get-docker/)
|
- [Docker](https://docs.docker.com/get-docker/)
|
||||||
- [Docker Compose](https://docs.docker.com/compose/install/)
|
- [Docker Compose](https://docs.docker.com/compose/install/)
|
||||||
|
|
||||||
|
@ -25,7 +26,8 @@ Additionally, you'll need to create a Discord bot application and obtain a token
|
||||||
|
|
||||||
### Running Luminara:
|
### Running Luminara:
|
||||||
|
|
||||||
1. Copy the contents from [`docker-compose.prod.yml`](docker-compose.prod.yml) to a new file named `docker-compose.yml` in an empty directory.
|
1. Copy the contents from [`docker-compose.prod.yml`](docker-compose.prod.yml) to a new file named `docker-compose.yml`
|
||||||
|
in an empty directory.
|
||||||
|
|
||||||
2. Copy the contents from [`.env.example`](.env.example) to a new file named `.env` in the same directory.
|
2. Copy the contents from [`.env.example`](.env.example) to a new file named `.env` in the same directory.
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
Versions currently being supported with security updates.
|
Versions currently being supported with security updates.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
|---------|--------------------|
|
||||||
| 2.x | :white_check_mark: |
|
| 2.x | :white_check_mark: |
|
||||||
| 1.x | :x: |
|
| 1.x | :x: |
|
||||||
| < 1.0 | :x: |
|
| < 1.0 | :x: |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ReactionListener(Cog):
|
||||||
:param message: The message to process.
|
:param message: The message to process.
|
||||||
"""
|
"""
|
||||||
if not message.author.bot and not BlacklistUserService.is_user_blacklisted(
|
if not message.author.bot and not BlacklistUserService.is_user_blacklisted(
|
||||||
message.author.id,
|
message.author.id,
|
||||||
):
|
):
|
||||||
await ReactionHandler(self.client, message).run_checks()
|
await ReactionHandler(self.client, message).run_checks()
|
||||||
|
|
||||||
|
|
|
@ -103,9 +103,9 @@ class XPHandler:
|
||||||
|
|
||||||
if role := self.guild.get_role(role_id):
|
if role := self.guild.get_role(role_id):
|
||||||
with contextlib.suppress(
|
with contextlib.suppress(
|
||||||
discord.Forbidden,
|
discord.Forbidden,
|
||||||
discord.NotFound,
|
discord.NotFound,
|
||||||
discord.HTTPException,
|
discord.HTTPException,
|
||||||
):
|
):
|
||||||
if isinstance(self.author, discord.Member):
|
if isinstance(self.author, discord.Member):
|
||||||
await self.author.add_roles(role, reason=reason)
|
await self.author.add_roles(role, reason=reason)
|
||||||
|
@ -114,16 +114,16 @@ class XPHandler:
|
||||||
if replace and isinstance(self.author, discord.Member):
|
if replace and isinstance(self.author, discord.Member):
|
||||||
if role := self.guild.get_role(previous or role_id):
|
if role := self.guild.get_role(previous or role_id):
|
||||||
with contextlib.suppress(
|
with contextlib.suppress(
|
||||||
discord.Forbidden,
|
discord.Forbidden,
|
||||||
discord.NotFound,
|
discord.NotFound,
|
||||||
discord.HTTPException,
|
discord.HTTPException,
|
||||||
):
|
):
|
||||||
await self.author.remove_roles(role, reason=reason)
|
await self.author.remove_roles(role, reason=reason)
|
||||||
|
|
||||||
async def get_level_channel(
|
async def get_level_channel(
|
||||||
self,
|
self,
|
||||||
message: discord.Message,
|
message: discord.Message,
|
||||||
guild_config: GuildConfig,
|
guild_config: GuildConfig,
|
||||||
) -> Optional[discord.TextChannel]:
|
) -> Optional[discord.TextChannel]:
|
||||||
"""
|
"""
|
||||||
Retrieves the level up notification channel for the guild.
|
Retrieves the level up notification channel for the guild.
|
||||||
|
@ -147,9 +147,9 @@ class XPHandler:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_level_message(
|
async def get_level_message(
|
||||||
guild_config: GuildConfig,
|
guild_config: GuildConfig,
|
||||||
level_config: XpService,
|
level_config: XpService,
|
||||||
author: discord.Member,
|
author: discord.Member,
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Retrieves the level up message for the user.
|
Retrieves the level up message for the user.
|
||||||
|
|
|
@ -8,22 +8,22 @@ from lib.constants import CONST
|
||||||
class EmbedBuilder:
|
class EmbedBuilder:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_embed(
|
def create_embed(
|
||||||
ctx,
|
ctx,
|
||||||
title=None,
|
title=None,
|
||||||
author_text=None,
|
author_text=None,
|
||||||
author_icon_url=None,
|
author_icon_url=None,
|
||||||
author_url=None,
|
author_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
color=None,
|
color=None,
|
||||||
footer_text=None,
|
footer_text=None,
|
||||||
footer_icon_url=None,
|
footer_icon_url=None,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
image_url=None,
|
image_url=None,
|
||||||
thumbnail_url=None,
|
thumbnail_url=None,
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
hide_author=False,
|
hide_author=False,
|
||||||
hide_author_icon=False,
|
hide_author_icon=False,
|
||||||
hide_timestamp=False,
|
hide_timestamp=False,
|
||||||
):
|
):
|
||||||
if not hide_author:
|
if not hide_author:
|
||||||
if not author_text:
|
if not author_text:
|
||||||
|
@ -63,20 +63,20 @@ class EmbedBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_error_embed(
|
def create_error_embed(
|
||||||
ctx,
|
ctx,
|
||||||
title=None,
|
title=None,
|
||||||
author_text=None,
|
author_text=None,
|
||||||
author_icon_url=None,
|
author_icon_url=None,
|
||||||
author_url=None,
|
author_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
footer_text=None,
|
footer_text=None,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
image_url=None,
|
image_url=None,
|
||||||
thumbnail_url=None,
|
thumbnail_url=None,
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
hide_author=False,
|
hide_author=False,
|
||||||
hide_author_icon=False,
|
hide_author_icon=False,
|
||||||
hide_timestamp=False,
|
hide_timestamp=False,
|
||||||
):
|
):
|
||||||
return EmbedBuilder.create_embed(
|
return EmbedBuilder.create_embed(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -99,20 +99,20 @@ class EmbedBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_success_embed(
|
def create_success_embed(
|
||||||
ctx,
|
ctx,
|
||||||
title=None,
|
title=None,
|
||||||
author_text=None,
|
author_text=None,
|
||||||
author_icon_url=None,
|
author_icon_url=None,
|
||||||
author_url=None,
|
author_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
footer_text=None,
|
footer_text=None,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
image_url=None,
|
image_url=None,
|
||||||
thumbnail_url=None,
|
thumbnail_url=None,
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
hide_author=False,
|
hide_author=False,
|
||||||
hide_author_icon=False,
|
hide_author_icon=False,
|
||||||
hide_timestamp=False,
|
hide_timestamp=False,
|
||||||
):
|
):
|
||||||
return EmbedBuilder.create_embed(
|
return EmbedBuilder.create_embed(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -135,20 +135,20 @@ class EmbedBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_info_embed(
|
def create_info_embed(
|
||||||
ctx,
|
ctx,
|
||||||
title=None,
|
title=None,
|
||||||
author_text=None,
|
author_text=None,
|
||||||
author_icon_url=None,
|
author_icon_url=None,
|
||||||
author_url=None,
|
author_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
footer_text=None,
|
footer_text=None,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
image_url=None,
|
image_url=None,
|
||||||
thumbnail_url=None,
|
thumbnail_url=None,
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
hide_author=False,
|
hide_author=False,
|
||||||
hide_author_icon=False,
|
hide_author_icon=False,
|
||||||
hide_timestamp=False,
|
hide_timestamp=False,
|
||||||
):
|
):
|
||||||
return EmbedBuilder.create_embed(
|
return EmbedBuilder.create_embed(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -171,20 +171,20 @@ class EmbedBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_warning_embed(
|
def create_warning_embed(
|
||||||
ctx,
|
ctx,
|
||||||
title=None,
|
title=None,
|
||||||
author_text=None,
|
author_text=None,
|
||||||
author_icon_url=None,
|
author_icon_url=None,
|
||||||
author_url=None,
|
author_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
footer_text=None,
|
footer_text=None,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
image_url=None,
|
image_url=None,
|
||||||
thumbnail_url=None,
|
thumbnail_url=None,
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
hide_author=False,
|
hide_author=False,
|
||||||
hide_author_icon=False,
|
hide_author_icon=False,
|
||||||
hide_timestamp=False,
|
hide_timestamp=False,
|
||||||
):
|
):
|
||||||
return EmbedBuilder.create_embed(
|
return EmbedBuilder.create_embed(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
@ -51,9 +51,9 @@ class IntroductionFinishButtons(View):
|
||||||
|
|
||||||
@discord.ui.button(label="Post it!", style=discord.ButtonStyle.green)
|
@discord.ui.button(label="Post it!", style=discord.ButtonStyle.green)
|
||||||
async def short_button_callback(
|
async def short_button_callback(
|
||||||
self,
|
self,
|
||||||
button: discord.ui.Button,
|
button: discord.ui.Button,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
) -> None:
|
) -> None:
|
||||||
await interaction.response.edit_message(view=None)
|
await interaction.response.edit_message(view=None)
|
||||||
self.clickedConfirm = True
|
self.clickedConfirm = True
|
||||||
|
@ -61,9 +61,9 @@ class IntroductionFinishButtons(View):
|
||||||
|
|
||||||
@discord.ui.button(label="Stop", style=discord.ButtonStyle.red)
|
@discord.ui.button(label="Stop", style=discord.ButtonStyle.red)
|
||||||
async def extended_button_callback(
|
async def extended_button_callback(
|
||||||
self,
|
self,
|
||||||
button: discord.ui.Button,
|
button: discord.ui.Button,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
) -> None:
|
) -> None:
|
||||||
await interaction.response.edit_message(view=None)
|
await interaction.response.edit_message(view=None)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ReactionHandler:
|
||||||
content = message.content.lower()
|
content = message.content.lower()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
content.startswith("Lumi ") or content.startswith("Lumi, ")
|
content.startswith("Lumi ") or content.startswith("Lumi, ")
|
||||||
) and content.endswith("?"):
|
) and content.endswith("?"):
|
||||||
response = random.choice(self.eightball)
|
response = random.choice(self.eightball)
|
||||||
await message.reply(content=response)
|
await message.reply(content=response)
|
||||||
|
|
|
@ -8,9 +8,9 @@ from services.blacklist_service import BlacklistUserService
|
||||||
|
|
||||||
|
|
||||||
async def blacklist_user(
|
async def blacklist_user(
|
||||||
ctx,
|
ctx,
|
||||||
user: discord.User,
|
user: discord.User,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
blacklist_service = BlacklistUserService(user.id)
|
blacklist_service = BlacklistUserService(user.id)
|
||||||
blacklist_service.add_to_blacklist(reason)
|
blacklist_service.add_to_blacklist(reason)
|
||||||
|
|
|
@ -39,11 +39,11 @@ class Config(commands.Cog):
|
||||||
@guild_only()
|
@guild_only()
|
||||||
@commands.has_permissions(manage_roles=True)
|
@commands.has_permissions(manage_roles=True)
|
||||||
async def xp_reward_command_add(
|
async def xp_reward_command_add(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
level: int,
|
level: int,
|
||||||
role: discord.Role,
|
role: discord.Role,
|
||||||
persistent: bool = False,
|
persistent: bool = False,
|
||||||
):
|
):
|
||||||
await xp_reward.add_reward(ctx, level, role.id, persistent)
|
await xp_reward.add_reward(ctx, level, role.id, persistent)
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,9 @@ async def set_boost_image(ctx, image_url: str | None):
|
||||||
|
|
||||||
|
|
||||||
async def create_boost_embed(
|
async def create_boost_embed(
|
||||||
member: discord.Member,
|
member: discord.Member,
|
||||||
template: str | None = None,
|
template: str | None = None,
|
||||||
image_url: str | None = None,
|
image_url: str | None = None,
|
||||||
):
|
):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
color=discord.Color.nitro_pink(),
|
color=discord.Color.nitro_pink(),
|
||||||
|
|
|
@ -77,8 +77,8 @@ async def set_welcome_template(ctx, text: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def create_greet_embed(
|
def create_greet_embed(
|
||||||
member: discord.Member,
|
member: discord.Member,
|
||||||
template: Optional[str] = None,
|
template: Optional[str] = None,
|
||||||
) -> discord.Embed:
|
) -> discord.Embed:
|
||||||
embed: discord.Embed = discord.Embed(
|
embed: discord.Embed = discord.Embed(
|
||||||
color=discord.Color.embed_background(),
|
color=discord.Color.embed_background(),
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Economy(commands.Cog):
|
||||||
aliases=["bal", "$"],
|
aliases=["bal", "$"],
|
||||||
description="Shows your current Lumi balance.",
|
description="Shows your current Lumi balance.",
|
||||||
help="Shows your current Lumi balance. The economy system is global, meaning your balance will be synced in "
|
help="Shows your current Lumi balance. The economy system is global, meaning your balance will be synced in "
|
||||||
"all servers.",
|
"all servers.",
|
||||||
contexts={discord.InteractionContextType.guild},
|
contexts={discord.InteractionContextType.guild},
|
||||||
)
|
)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
|
|
|
@ -178,12 +178,12 @@ async def cmd(ctx, bet: int):
|
||||||
|
|
||||||
|
|
||||||
def blackjack_show(
|
def blackjack_show(
|
||||||
ctx,
|
ctx,
|
||||||
bet,
|
bet,
|
||||||
player_hand,
|
player_hand,
|
||||||
dealer_hand,
|
dealer_hand,
|
||||||
player_hand_value,
|
player_hand_value,
|
||||||
dealer_hand_value,
|
dealer_hand_value,
|
||||||
):
|
):
|
||||||
current_time = datetime.now(est).strftime("%I:%M %p")
|
current_time = datetime.now(est).strftime("%I:%M %p")
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|
|
@ -132,8 +132,8 @@ class LeaderboardCommandView(discord.ui.View):
|
||||||
embed.set_author(name=CONST.STRINGS["xp_lb_author"], icon_url=icon)
|
embed.set_author(name=CONST.STRINGS["xp_lb_author"], icon_url=icon)
|
||||||
|
|
||||||
for rank, (user_id, xp, level, xp_needed_for_next_level) in enumerate(
|
for rank, (user_id, xp, level, xp_needed_for_next_level) in enumerate(
|
||||||
xp_lb[:5],
|
xp_lb[:5],
|
||||||
start=1,
|
start=1,
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
member = await self.ctx.guild.fetch_member(user_id)
|
member = await self.ctx.guild.fetch_member(user_id)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Misc(commands.Cog):
|
||||||
aliases=["intro", "introduce"],
|
aliases=["intro", "introduce"],
|
||||||
description="This command can only be used in DMs.",
|
description="This command can only be used in DMs.",
|
||||||
help="Introduce yourself. For now this command "
|
help="Introduce yourself. For now this command "
|
||||||
"can only be done in ONE server and only in Lumi's DMs.",
|
"can only be done in ONE server and only in Lumi's DMs.",
|
||||||
contexts={discord.InteractionContextType.bot_dm},
|
contexts={discord.InteractionContextType.bot_dm},
|
||||||
)
|
)
|
||||||
@commands.dm_only()
|
@commands.dm_only()
|
||||||
|
|
|
@ -35,8 +35,8 @@ async def cmd(self, ctx: bridge.Context) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
if not channel or isinstance(
|
if not channel or isinstance(
|
||||||
channel,
|
channel,
|
||||||
(discord.ForumChannel, discord.CategoryChannel),
|
(discord.ForumChannel, discord.CategoryChannel),
|
||||||
):
|
):
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=EmbedBuilder.create_error_embed(
|
embed=EmbedBuilder.create_error_embed(
|
||||||
|
|
|
@ -10,9 +10,9 @@ _xkcd = Client()
|
||||||
|
|
||||||
|
|
||||||
async def print_comic(
|
async def print_comic(
|
||||||
ctx: bridge.Context,
|
ctx: bridge.Context,
|
||||||
latest: bool = False,
|
latest: bool = False,
|
||||||
number: Optional[int] = None,
|
number: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
if latest:
|
if latest:
|
||||||
|
|
|
@ -20,11 +20,11 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(ban_members=True)
|
@commands.bot_has_permissions(ban_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def ban_command(
|
async def ban_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await ban.ban_user(self, ctx, target, reason)
|
await ban.ban_user(self, ctx, target, reason)
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(kick_members=True)
|
@commands.bot_has_permissions(kick_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def kick_command(
|
async def kick_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await kick.kick_user(self, ctx, target, reason)
|
await kick.kick_user(self, ctx, target, reason)
|
||||||
|
|
||||||
|
@ -106,11 +106,11 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(ban_members=True)
|
@commands.bot_has_permissions(ban_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def softban_command(
|
async def softban_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await softban.softban_user(ctx, target, reason)
|
await softban.softban_user(ctx, target, reason)
|
||||||
|
|
||||||
|
@ -125,12 +125,12 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(moderate_members=True)
|
@commands.bot_has_permissions(moderate_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def timeout_command(
|
async def timeout_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
duration: str,
|
duration: str,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await timeout.timeout_user(self, ctx, target, duration, reason)
|
await timeout.timeout_user(self, ctx, target, duration, reason)
|
||||||
|
|
||||||
|
@ -145,11 +145,11 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(ban_members=True)
|
@commands.bot_has_permissions(ban_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def unban_command(
|
async def unban_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await ban.unban_user(ctx, target, reason)
|
await ban.unban_user(ctx, target, reason)
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ class Moderation(commands.Cog):
|
||||||
@commands.bot_has_permissions(moderate_members=True)
|
@commands.bot_has_permissions(moderate_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def untimeout_command(
|
async def untimeout_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await timeout.untimeout_user(ctx, target, reason)
|
await timeout.untimeout_user(ctx, target, reason)
|
||||||
|
|
||||||
|
@ -182,11 +182,11 @@ class Moderation(commands.Cog):
|
||||||
@bridge.has_permissions(kick_members=True)
|
@bridge.has_permissions(kick_members=True)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def warn_command(
|
async def warn_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
*,
|
*,
|
||||||
reason: str | None = None,
|
reason: str | None = None,
|
||||||
):
|
):
|
||||||
await warn.warn_user(ctx, target, reason)
|
await warn.warn_user(ctx, target, reason)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ async def view_all_cases_in_guild(ctx, guild_id: int):
|
||||||
|
|
||||||
pages_list = []
|
pages_list = []
|
||||||
for i in range(0, len(cases), 10):
|
for i in range(0, len(cases), 10):
|
||||||
chunk = cases[i : i + 10]
|
chunk = cases[i: i + 10]
|
||||||
embed = create_case_list_embed(
|
embed = create_case_list_embed(
|
||||||
ctx,
|
ctx,
|
||||||
chunk,
|
chunk,
|
||||||
|
@ -79,7 +79,7 @@ async def view_all_cases_by_mod(ctx, guild_id: int, moderator: discord.Member):
|
||||||
|
|
||||||
pages_list = []
|
pages_list = []
|
||||||
for i in range(0, len(cases), 10):
|
for i in range(0, len(cases), 10):
|
||||||
chunk = cases[i : i + 10]
|
chunk = cases[i: i + 10]
|
||||||
embed = create_case_list_embed(
|
embed = create_case_list_embed(
|
||||||
ctx,
|
ctx,
|
||||||
chunk,
|
chunk,
|
||||||
|
|
|
@ -14,11 +14,11 @@ from modules.moderation.utils.case_handler import create_case
|
||||||
|
|
||||||
|
|
||||||
async def timeout_user(
|
async def timeout_user(
|
||||||
cog,
|
cog,
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
duration: str,
|
duration: str,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
):
|
):
|
||||||
bot_member = await MemberConverter().convert(ctx, str(ctx.bot.user.id))
|
bot_member = await MemberConverter().convert(ctx, str(ctx.bot.user.id))
|
||||||
await async_actionable(target, ctx.author, bot_member)
|
await async_actionable(target, ctx.author, bot_member)
|
||||||
|
|
|
@ -5,9 +5,9 @@ from lib.exceptions.LumiExceptions import LumiException
|
||||||
|
|
||||||
|
|
||||||
async def async_actionable(
|
async def async_actionable(
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
invoker: discord.Member,
|
invoker: discord.Member,
|
||||||
bot_user: discord.Member,
|
bot_user: discord.Member,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Checks if the invoker and client have a higher role than the target user.
|
Checks if the invoker and client have a higher role than the target user.
|
||||||
|
|
|
@ -10,13 +10,13 @@ from lib.formatter import format_seconds_to_duration_string
|
||||||
|
|
||||||
|
|
||||||
def create_case_embed(
|
def create_case_embed(
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
case_number: int,
|
case_number: int,
|
||||||
action_type: str,
|
action_type: str,
|
||||||
reason: Optional[str],
|
reason: Optional[str],
|
||||||
timestamp: Optional[datetime.datetime] = None,
|
timestamp: Optional[datetime.datetime] = None,
|
||||||
duration: Optional[int] = None,
|
duration: Optional[int] = None,
|
||||||
) -> discord.Embed:
|
) -> discord.Embed:
|
||||||
embed = EmbedBuilder.create_warning_embed(
|
embed = EmbedBuilder.create_warning_embed(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
@ -13,12 +13,12 @@ modlog_service = ModLogService()
|
||||||
|
|
||||||
|
|
||||||
async def create_case(
|
async def create_case(
|
||||||
ctx,
|
ctx,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
action_type: str,
|
action_type: str,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
duration: Optional[int] = None,
|
duration: Optional[int] = None,
|
||||||
expires_at: Optional[str] = None,
|
expires_at: Optional[str] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Creates a new moderation case and logs it to the modlog channel if configured.
|
Creates a new moderation case and logs it to the modlog channel if configured.
|
||||||
|
@ -90,10 +90,10 @@ async def create_case(
|
||||||
|
|
||||||
|
|
||||||
async def edit_case_modlog(
|
async def edit_case_modlog(
|
||||||
ctx,
|
ctx,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
case_number: int,
|
case_number: int,
|
||||||
new_reason: str,
|
new_reason: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Edits the reason for an existing case and updates the modlog message if it exists.
|
Edits the reason for an existing case and updates the modlog message if it exists.
|
||||||
|
|
|
@ -28,11 +28,11 @@ class Triggers(commands.Cog):
|
||||||
)
|
)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def add_text_reaction_command(
|
async def add_text_reaction_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
trigger_text: str,
|
trigger_text: str,
|
||||||
response: str,
|
response: str,
|
||||||
is_full_match: bool,
|
is_full_match: bool,
|
||||||
):
|
):
|
||||||
await add_reaction(ctx, trigger_text, response, None, False, is_full_match)
|
await add_reaction(ctx, trigger_text, response, None, False, is_full_match)
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ class Triggers(commands.Cog):
|
||||||
)
|
)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def add_emoji_reaction_command(
|
async def add_emoji_reaction_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
trigger_text: str,
|
trigger_text: str,
|
||||||
emoji: discord.Emoji,
|
emoji: discord.Emoji,
|
||||||
is_full_match: bool,
|
is_full_match: bool,
|
||||||
):
|
):
|
||||||
await add_reaction(ctx, trigger_text, None, emoji.id, True, is_full_match)
|
await add_reaction(ctx, trigger_text, None, emoji.id, True, is_full_match)
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ class Triggers(commands.Cog):
|
||||||
)
|
)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def delete_reaction_command(
|
async def delete_reaction_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
reaction_id: int,
|
reaction_id: int,
|
||||||
):
|
):
|
||||||
await delete_reaction(ctx, reaction_id)
|
await delete_reaction(ctx, reaction_id)
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ class Triggers(commands.Cog):
|
||||||
)
|
)
|
||||||
@guild_only()
|
@guild_only()
|
||||||
async def list_reactions_command(
|
async def list_reactions_command(
|
||||||
self,
|
self,
|
||||||
ctx,
|
ctx,
|
||||||
):
|
):
|
||||||
await list_reactions(ctx)
|
await list_reactions(ctx)
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@ from services.reactions_service import CustomReactionsService
|
||||||
|
|
||||||
|
|
||||||
async def add_reaction(
|
async def add_reaction(
|
||||||
ctx: bridge.Context,
|
ctx: bridge.Context,
|
||||||
trigger_text: str,
|
trigger_text: str,
|
||||||
response: Optional[str],
|
response: Optional[str],
|
||||||
emoji_id: Optional[int],
|
emoji_id: Optional[int],
|
||||||
is_emoji: bool,
|
is_emoji: bool,
|
||||||
is_full_match: bool,
|
is_full_match: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
if ctx.guild is None:
|
if ctx.guild is None:
|
||||||
return
|
return
|
||||||
|
@ -25,15 +25,15 @@ async def add_reaction(
|
||||||
creator_id: int = ctx.author.id
|
creator_id: int = ctx.author.id
|
||||||
|
|
||||||
if not await check_reaction_limit(
|
if not await check_reaction_limit(
|
||||||
reaction_service,
|
reaction_service,
|
||||||
guild_id,
|
guild_id,
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not await check_existing_trigger(
|
if not await check_existing_trigger(
|
||||||
reaction_service,
|
reaction_service,
|
||||||
guild_id,
|
guild_id,
|
||||||
trigger_text,
|
trigger_text,
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ async def add_reaction(
|
||||||
|
|
||||||
|
|
||||||
async def check_reaction_limit(
|
async def check_reaction_limit(
|
||||||
reaction_service: CustomReactionsService,
|
reaction_service: CustomReactionsService,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
limit_reached = await reaction_service.count_custom_reactions(guild_id) >= 100
|
limit_reached = await reaction_service.count_custom_reactions(guild_id) >= 100
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ async def check_reaction_limit(
|
||||||
|
|
||||||
|
|
||||||
async def check_existing_trigger(
|
async def check_existing_trigger(
|
||||||
reaction_service: CustomReactionsService,
|
reaction_service: CustomReactionsService,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
trigger_text: str,
|
trigger_text: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
existing_trigger = await reaction_service.find_trigger(guild_id, trigger_text)
|
existing_trigger = await reaction_service.find_trigger(guild_id, trigger_text)
|
||||||
|
|
||||||
|
|
1210
poetry.lock
generated
1210
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -69,14 +69,14 @@ class Dailies:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
check_1: bool = (
|
check_1: bool = (
|
||||||
self.claimed_at.date() == (self.time_now - timedelta(days=1)).date()
|
self.claimed_at.date() == (self.time_now - timedelta(days=1)).date()
|
||||||
)
|
)
|
||||||
check_2: bool = (
|
check_2: bool = (
|
||||||
self.claimed_at.date() == (self.time_now - timedelta(days=2)).date()
|
self.claimed_at.date() == (self.time_now - timedelta(days=2)).date()
|
||||||
)
|
)
|
||||||
check_3: bool = (
|
check_3: bool = (
|
||||||
self.claimed_at.date() == self.time_now.date()
|
self.claimed_at.date() == self.time_now.date()
|
||||||
and self.claimed_at < self.reset_time
|
and self.claimed_at < self.reset_time
|
||||||
)
|
)
|
||||||
|
|
||||||
return check_1 or check_2 or check_3
|
return check_1 or check_2 or check_3
|
||||||
|
|
|
@ -8,15 +8,15 @@ class CaseService:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_case(
|
def create_case(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
target_id: int,
|
target_id: int,
|
||||||
moderator_id: int,
|
moderator_id: int,
|
||||||
action_type: str,
|
action_type: str,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
duration: Optional[int] = None,
|
duration: Optional[int] = None,
|
||||||
expires_at: Optional[str] = None,
|
expires_at: Optional[str] = None,
|
||||||
modlog_message_id: Optional[int] = None,
|
modlog_message_id: Optional[int] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
# Get the next case number for the guild
|
# Get the next case number for the guild
|
||||||
query: str = """
|
query: str = """
|
||||||
|
@ -63,10 +63,10 @@ class CaseService:
|
||||||
execute_query(query, (guild_id, case_number))
|
execute_query(query, (guild_id, case_number))
|
||||||
|
|
||||||
def edit_case_reason(
|
def edit_case_reason(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
case_number: int,
|
case_number: int,
|
||||||
new_reason: Optional[str] = None,
|
new_reason: Optional[str] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
query = """
|
query = """
|
||||||
UPDATE cases
|
UPDATE cases
|
||||||
|
@ -103,9 +103,9 @@ class CaseService:
|
||||||
return result[0] if result else None
|
return result[0] if result else None
|
||||||
|
|
||||||
def fetch_case_by_guild_and_number(
|
def fetch_case_by_guild_and_number(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
case_number: int,
|
case_number: int,
|
||||||
) -> Optional[Dict[str, Any]]:
|
) -> Optional[Dict[str, Any]]:
|
||||||
query: str = """
|
query: str = """
|
||||||
SELECT * FROM cases
|
SELECT * FROM cases
|
||||||
|
@ -126,9 +126,9 @@ class CaseService:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def fetch_cases_by_target(
|
def fetch_cases_by_target(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
target_id: int,
|
target_id: int,
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
query: str = """
|
query: str = """
|
||||||
SELECT * FROM cases
|
SELECT * FROM cases
|
||||||
|
@ -139,9 +139,9 @@ class CaseService:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def fetch_cases_by_moderator(
|
def fetch_cases_by_moderator(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
moderator_id: int,
|
moderator_id: int,
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
query: str = """
|
query: str = """
|
||||||
SELECT * FROM cases
|
SELECT * FROM cases
|
||||||
|
@ -155,9 +155,9 @@ class CaseService:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def fetch_cases_by_action_type(
|
def fetch_cases_by_action_type(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
action_type: str,
|
action_type: str,
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
query: str = """
|
query: str = """
|
||||||
SELECT * FROM cases
|
SELECT * FROM cases
|
||||||
|
|
|
@ -9,9 +9,9 @@ class CustomReactionsService:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def find_trigger(
|
async def find_trigger(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
message_content: str,
|
message_content: str,
|
||||||
) -> Optional[Dict[str, Any]]:
|
) -> Optional[Dict[str, Any]]:
|
||||||
message_content = message_content.lower()
|
message_content = message_content.lower()
|
||||||
query = """
|
query = """
|
||||||
|
@ -24,8 +24,8 @@ class CustomReactionsService:
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
if result := database.select_query(
|
if result := database.select_query(
|
||||||
query,
|
query,
|
||||||
(guild_id, message_content, message_content, guild_id),
|
(guild_id, message_content, message_content, guild_id),
|
||||||
):
|
):
|
||||||
reaction = result[0] # Get the first result from the list
|
reaction = result[0] # Get the first result from the list
|
||||||
return {
|
return {
|
||||||
|
@ -96,15 +96,15 @@ class CustomReactionsService:
|
||||||
]
|
]
|
||||||
|
|
||||||
async def create_custom_reaction(
|
async def create_custom_reaction(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
creator_id: int,
|
creator_id: int,
|
||||||
trigger_text: str,
|
trigger_text: str,
|
||||||
response: Optional[str] = None,
|
response: Optional[str] = None,
|
||||||
emoji_id: Optional[int] = None,
|
emoji_id: Optional[int] = None,
|
||||||
is_emoji: bool = False,
|
is_emoji: bool = False,
|
||||||
is_full_match: bool = False,
|
is_full_match: bool = False,
|
||||||
is_global: bool = True,
|
is_global: bool = True,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
if await self.count_custom_reactions(guild_id) >= 100:
|
if await self.count_custom_reactions(guild_id) >= 100:
|
||||||
return False
|
return False
|
||||||
|
@ -130,13 +130,13 @@ class CustomReactionsService:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def edit_custom_reaction(
|
async def edit_custom_reaction(
|
||||||
self,
|
self,
|
||||||
reaction_id: int,
|
reaction_id: int,
|
||||||
new_response: Optional[str] = None,
|
new_response: Optional[str] = None,
|
||||||
new_emoji_id: Optional[int] = None,
|
new_emoji_id: Optional[int] = None,
|
||||||
is_emoji: Optional[bool] = None,
|
is_emoji: Optional[bool] = None,
|
||||||
is_full_match: Optional[bool] = None,
|
is_full_match: Optional[bool] = None,
|
||||||
is_global: Optional[bool] = None,
|
is_global: Optional[bool] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
query = """
|
query = """
|
||||||
UPDATE custom_reactions
|
UPDATE custom_reactions
|
||||||
|
|
|
@ -30,11 +30,11 @@ class Comic:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
xkcd_dict: dict[str, Any],
|
xkcd_dict: dict[str, Any],
|
||||||
raw_image: bytes | None = None,
|
raw_image: bytes | None = None,
|
||||||
comic_url: str | None = None,
|
comic_url: str | None = None,
|
||||||
explanation_url: str | None = None,
|
explanation_url: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.id: int | None = xkcd_dict.get("num")
|
self.id: int | None = xkcd_dict.get("num")
|
||||||
self.date: datetime.date | None = self._determine_date(xkcd_dict)
|
self.date: datetime.date | None = self._determine_date(xkcd_dict)
|
||||||
|
@ -104,9 +104,9 @@ class Comic:
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
api_url: str = "https://xkcd.com",
|
api_url: str = "https://xkcd.com",
|
||||||
explanation_wiki_url: str = "https://www.explainxkcd.com/wiki/index.php/",
|
explanation_wiki_url: str = "https://www.explainxkcd.com/wiki/index.php/",
|
||||||
) -> None:
|
) -> None:
|
||||||
self._api_url = api_url
|
self._api_url = api_url
|
||||||
self._explanation_wiki_url = explanation_wiki_url
|
self._explanation_wiki_url = explanation_wiki_url
|
||||||
|
|
|
@ -132,9 +132,9 @@ class XpService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_progress_bar(
|
def generate_progress_bar(
|
||||||
current_value: int,
|
current_value: int,
|
||||||
target_value: int,
|
target_value: int,
|
||||||
bar_length: int = 10,
|
bar_length: int = 10,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Generates an XP progress bar based on the current level and XP.
|
Generates an XP progress bar based on the current level and XP.
|
||||||
|
|
Loading…
Reference in a new issue