Open ChaseCares opened 7 months ago
Is this different than the automatic inference of the current channel, e.g. [p]bbl add adds the current channel? Maybe we could also except a named channel?
If you still define a default value (like None
), it will use that default value when the parameter is omitted, which you can test for to replace with the dynamic value for the current channel. You could also use commands.CurrentChannel
as the default value (example) to have it default to the channel the command was executed in automatically.
Does this mean that if ctx.author.bot: return is also not required?
Within a command, it is not required, since bots cannot invoke commands. Within a listener, you do need to manually filter out bots (especially bot messages in on_message
listeners).
Amazing, thank you so much! I was leaving notes for myself so I would remember when I needed to do, I didn't mean to ping you.
I greatly appreciate your time and information.
Flame442 recommendations
[ ] You can directly use a discord.TextChannel or discord.GuildChannel typehint in the parameters of a command to auto-convert/validate that parameter as a channel, rather than requiring the user to enter an int. TODO: (research) Is this different than the automatic inference of the current channel, e.g.
[p]bbl add
adds the current channel? Maybe we could also except a named channel?[x] Optional in a command has extra behavior if there are parameters after it which may be confusing if not expected. It's generally advised to make optional parameters by defining a default (parameter: int=None).
[x] broadcastboxlive stores a list of channels where it is posting updates in a guild, but only one value for the message. This means that all but the last message will be unable to update by editing. You are already looping over the message history and trying to find a message with the correct embed title to know what to update and requiring that to be found, why not just use that message object?
[x] obj.len() is just the more internal version of len(obj).
[x] You can use @commands.guild_only() to require a command to be used in a guild. You do use this in some commands, but in others you manually check if ctx.guild is None instead.
[ ] [p]bbl interval can be used by anyone with manage_guild in a guild the bot is in, but affects the bot-wide task. TODO: (code) Make this actually guild specific
[ ] ctx.message.author.bot will never be True since bots cannot invoke commands. TODO: (research) Does this mean that if ctx.author.bot: return is also not required?
Originally posted by @Flame442 in https://github.com/Cog-Creators/Red-Index/issues/126#issuecomment-1963373777