Implement !tunnel command - #3516
Conversation
5b4d35e to
9d2c86c
Compare
…east active off-topic channel selection)
9d2c86c to
3bf675d
Compare
|
I do have a couple of questions though, first, so currently I have made it so that only Another thing is that if I change the command method signature to use Then also, if I use the Should there be checks for whether the given channel is a DM channel or some such? Currently it just seems to treat it as incorrect channel ID (probably because it's not a Similarly, what to do about Is there a simple way to do overloads for this command? So that with one argument it's Any shortcuts/convenience functions I should use for say permission checks from the existing code base? Does this need unit or integration tests? |
jb3
left a comment
There was a problem hiding this comment.
Nice initial implementation, a few feedback comments. Will address your other comments in a second.
Sounds fine — with the necessary cooldown added as mentioned so users cannot spam this in places we have less visibility.
This sounds weird, do you get the same if you try use
I wonder if using a https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.TextChannelConverter might help?
You can use a guild-only decorator to enforce this.
Same as above.
Not easily without doing most of the argument handling yourself. I was going to suggest that for this initial implementation though we ditch the source channel support. Especially since the user who did the tunneling isn't mentioned in the tunneling messages it seems ripe for abuse (e.g. someone spamming in bot commands with another source & dest). For now, let's keep things simple and just implement an optional destination channel.
You can if you want to (and if you remove the source stuff it should be easier), we do have some utilities for mocking Discord components here and it's not too hard to add new bits. |
|
Also, on the last point about abuse: can we include the user who tunneled on both the source and destination message (username is fine, doesn't need to be a mention), so that we can easily see any problems without having to look through message logs. |
wookie184
left a comment
There was a problem hiding this comment.
Thanks for working on this :)
Potential simplification:
- Get the channels in the
cog_loadand store them in in a list e.g.self.channels - replace
get_least_active_channel_idwithget_least_active_channelthat looks something likereturn min(self.channels, key=lambda c: thattimeutilthing(c.last_message_id) - Then the
channel_id_to_timestamplogic +on_messagearen't needed at all, and it's a bit simpler as you're passing the channel around instead of the channel id (don't need to fetch it).
…hannel.last_message docs' suggestion channel.last_message: "For a slightly more reliable method of fetching the last message, consider using either history or fetch_message with the last_message_id attribute."
…issing from the cache on load
…nce it doesn't appear to be super necessary here
Co-authored-by: Joe Banks <joe@jb3.dev>
… of .get (for typing purposes)
…nt permanent source_channel
…hor id (as a ping) in the message as well (to prevent/detect potential abuse)
…ge in a channel (from its id)
…east recent message to `.last_message_id` and check the timestamp via `discord.utils.snowflake_time`
…ng `self.get_least_active_channel` (instead of `<that>_id`). Also ask for a raw channel string as the argument so we can explicitly attempt to convert it to a text channel, otherwise using something like `discord.guild.GuildChannel` for `destination_channel` makes this command be interpreted as a tag and if `discord.TextChannel` is used, if the destination channel cannot be converted to an actual `discord.TextChannel`, it will silently fail that step and simply set `destination_channel` to `None` (then follow the normal logic flow of this function)
Yes
Yes, it does, it seems I then just annotate the destination channel as Now, since the text uses the word "continued", should the command have an alias called "continue" as well? I quite like "tunnel", I think it's fun, but if the text now uses "continued", it might be more intuitive to have an option to call it via such an alias as well? I'm not sure, tbh, if the command is called "tunnel", then maybe it's not necessary to use the word "continued" in the text and we can use the word "tunneled" in the text as well, since it shouldn't be too confusing on what it means given the invocation of the command is probably gonna be pretty much nearby and also one could infer from the fact that there are two messages that link to each other in a "tunnel-like fashion". Not sure. I saw there was a decorator for cooldown where some roles can be excluded from that ( Otherwise, I think this is ready for another review, I might eventually maybe add those integration tests as well, but who knows, that might take another month to get there 😅 |
Fixes #3512