-
Notifications
You must be signed in to change notification settings - Fork 0
User auto-join club #17
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cd4971a
add auto join
TitouanDor 975eada
save into the db the id of the autorole message
TitouanDor 26188f4
select the correct club
TitouanDor 92fbfae
remove hardcoding id
TitouanDor ea1bcff
removing unecessary line
TitouanDor 16c5ee0
add auto_role_channel_id to the .toml
TitouanDor f6d25cf
nomore error when creating the club
TitouanDor 6bee9a3
resole not removing the role in the channel auto role
TitouanDor a783984
add type of payload
TitouanDor 857ca04
add description to commands and try to stop the ratelimite of stop_club
TitouanDor e6fa9d9
requests changes
TitouanDor 216d106
resolve error on reaction
TitouanDor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| if TYPE_CHECKING: | ||
| from discord import RawReactionActionEvent | ||
| from discord.ext import commands | ||
|
|
||
| from src.client import ClubSchema # noqa TC001 | ||
| from src.db.models import Club | ||
| from src.services.club import ClubService | ||
| from src.settings import Settings | ||
|
|
||
| if TYPE_CHECKING: | ||
| from src.main import AeBot | ||
|
|
||
|
|
||
| class RoleCog(commands.GroupCog, group_name="role"): | ||
| def __init__(self, bot: AeBot): | ||
| self.settings = Settings() | ||
| self.club_service = ClubService(bot) | ||
| self.bot = bot | ||
|
|
||
| @commands.Cog.listener() | ||
| async def on_raw_reaction_add(self, payload: RawReactionActionEvent): | ||
| if payload.guild_id is None: | ||
| return | ||
|
|
||
| guild = self.bot.get_guild(payload.guild_id) | ||
| member = guild.get_member(payload.user_id) | ||
|
|
||
| if member == self.bot.user: | ||
| return | ||
|
|
||
| channel = self.bot.get_channel(payload.channel_id) | ||
| message = await channel.fetch_message(payload.message_id) | ||
| emoji = str(payload.emoji) | ||
| db_club = Club.get(Club.message_autorole_id == message.id) | ||
|
|
||
| if not db_club: | ||
| return | ||
|
|
||
| elif emoji != "✅": | ||
| await message.remove_reaction(payload.emoji, member) | ||
|
|
||
| await self.club_service.add_member(db_club, member) | ||
|
|
||
| @commands.Cog.listener() | ||
| async def on_raw_reaction_remove(self, payload: RawReactionActionEvent): | ||
| if payload.guild_id is None: | ||
| return | ||
|
|
||
| guild = self.bot.get_guild(payload.guild_id) | ||
| member = guild.get_member(payload.user_id) | ||
|
|
||
| if member == self.bot.user: | ||
| return | ||
|
|
||
| channel = self.bot.get_channel(payload.channel_id) | ||
| message = await channel.fetch_message(payload.message_id) | ||
| emoji = str(payload.emoji) | ||
|
|
||
| db_club = Club.get(Club.message_autorole_id == message.id) | ||
|
|
||
| if not db_club or emoji != "✅": | ||
| return | ||
|
|
||
| await self.club_service.remove_member(db_club, member, _former=0) | ||
|
TitouanDor marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.