-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow admins to kick members from a team #16
Conversation
Since leave_team and kick_member had essentially the same code, it has been abstracted out of both methods and placed in a separate file. |
hey nice work! I feel like nitpicking ;;-; but I think this is too DRY. Generally when you DRY up a piece of code, you want its to be a logical unit that's testable - which this context code isn't quite. A better option would be to say, have a function that handles the deletion of a player, and another function that handles the deletion of a team + all the channels - then they would be much more testable. If that doesn't quite make sense, let me know! |
mhmm I think, at least for me, that cogs are the "front-end" of discord bots and should handle the messages instead of context - passing in a boolean to control how the message is sent feels like a code smell to me |
I'm not sure what you mean by code smell but I've fixed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just some small nitpicks!
…ams. See PR for more details.
…cord's official "kick" command
This is an important ability so that team members that are causing grievances can be removed from a team that they may otherwise be unwilling to leave.
EDIT:
Upon abstracting the code for removing players from a team (since the code for kicking a player is largely the same as a player leaving by themself), we encountered CommandInvokeErrors.
Specifically
discord.app_commands.errors.CommandInvokeError: Command 'kick_member' raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message
This happens when the code attempts to respond to an interaction in a channel that has been deleted. This did not occur before the abstraction of code because the interaction received a response before the channels were deleted. However, post-abstraction the folllowup response is only sent after the deletion of channels. This is a little hard to get around. We can possibly leave the actual deletion of the channels to the individual cog commands but that is not an ideal solution. We can also pass in the interaction to the context command and allow it to respond to the interaction.
However, we've chosen to simply catch the error when it happens and ignore it.