[V3 config] Create voice_channels etc for config #2248

Closed
opened 2018-10-16 17:54:56 +02:00 by The-Tasty-Jaffa · 10 comments
The-Tasty-Jaffa commented 2018-10-16 17:54:56 +02:00 (Migrated from github.com)

Feature request

Select the type of feature you are requesting:

  • Cog
  • Command
  • API functionality

Describe your requested feature

I'm suggesting renaming the current Config.channels to Config.text_channels because it is more clear. Also changing the name allows for clear use of other defaults such as Voice channels and categories.

By allowing the existence of Config.voice_channels and Config.category_channels would allow cog creators to have a different way of using config.

An example of where this would be incredibly useful would be in my Tempvoice cog, pswd cog or any other cog that stores data about voice/category channels.

# Feature request <!-- This template is for feature requests. Please fill out the following: --> #### Select the type of feature you are requesting: <!-- To check a box, replace the space between the [] with a x --> - [ ] Cog - [ ] Command - [X] API functionality #### Describe your requested feature <!-- If you are requesting API functionality: - Describe what it should do - Note whether it is to extend existing functionality or introduce new functionality --> I'm suggesting renaming the current `Config.channels` to `Config.text_channels` because it is more clear. Also changing the name allows for clear use of other defaults such as Voice channels and categories. By allowing the existence of `Config.voice_channels` and `Config.category_channels` would allow cog creators to have a different way of using config. An example of where this would be incredibly useful would be in my Tempvoice cog, pswd cog or any other cog that stores data about voice/category channels.
mikeshardmind commented 2018-10-16 17:59:30 +02:00 (Migrated from github.com)

Just an FYI, Config.channel does already support anything which has an id attribute castable to both a str and int (I might even be abusing this behavior of it in some places...)

While I do support this improvement as you may want different registered defaults for different channel types, you can use a sentinel value in your defaults to signify this until this is handled.

Just an FYI, `Config.channel` does already support anything which has an id attribute castable to both a str and int (I might even be abusing this behavior of it in some places...) While I do support this improvement as you may want different registered defaults for different channel types, you can use a sentinel value in your defaults to signify this until this is handled.
The-Tasty-Jaffa commented 2018-10-16 18:02:50 +02:00 (Migrated from github.com)

Just an FYI, Config.channel does already support anything which has an id attribute castable to str. (I might even be abusing this behavior of it in some places...)

While I do support this improvement as you may want different registered defaults for different channel types, you can use a sentinel value in your defaults to signify this until this is handled.

I don't see any information about this in the docs... just the one line which says > Config.channel() which takes discord.TextChannel

> Just an FYI, `Config.channel` does already support anything which has an id attribute castable to str. (I might even be abusing this behavior of it in some places...) > > While I do support this improvement as you may want different registered defaults for different channel types, you can use a sentinel value in your defaults to signify this until this is handled. I don't see any information about this in the docs... just the one line which says > `Config.channel() which takes discord.TextChannel`
mikeshardmind commented 2018-10-16 18:09:44 +02:00 (Migrated from github.com)

I'm aware the docs don't elaborate on this fully, which is why for now I'm informing you the actual behavior used. There's no checking for type done there, it just grabs the id, and makes it a str as a key in a config identifier sequence. I've also edited it should be castable to an int as well.

If you'd like to PR that it accepts any discord.abc.GuildChannel instead, this could easily be accepted, otherwise, someone else will get to it when they can. (While the type could be wider, it would be better not to promote this usage, and add new methods for custom objects later)

I'm aware the docs don't elaborate on this fully, which is why for now I'm informing you the actual behavior used. There's no checking for type done there, it just grabs the id, and makes it a str as a key in a config identifier sequence. I've also edited it should be castable to an int as well. If you'd like to PR that it accepts any `discord.abc.GuildChannel` instead, this could easily be accepted, otherwise, someone else will get to it when they can. (While the type could be wider, it would be better not to promote this usage, and add new methods for custom objects later)
Tobotimus commented 2018-12-21 00:45:27 +01:00 (Migrated from github.com)

I agree with your sentiment, and there are quite a few things we've been thinking about changing in config. For now these will be on hold until we have a final release for 3.0 and have made some more progress on 3.1. Thanks :)

I agree with your sentiment, and there are quite a few things we've been thinking about changing in config. For now these will be on hold until we have a final release for 3.0 and have made some more progress on 3.1. Thanks :)
mikeshardmind commented 2019-05-16 03:53:20 +02:00 (Migrated from github.com)

I think rather than implement this as breaking, we should retain the old behavior as there may be settings which are not channel type specific and have no need of the specificity as a result, while adding a group for each channel type.

I think rather than implement this as breaking, we should retain the old behavior as there may be settings which are not channel type specific and have no need of the specificity as a result, while adding a group for each channel type.
mikeshardmind commented 2019-05-17 04:34:55 +02:00 (Migrated from github.com)

sigh after getting around to looking into this a bit more, I noticed a "fun" detail in config.


    GLOBAL = "GLOBAL"
    GUILD = "GUILD"
    CHANNEL = "TEXTCHANNEL"
    ROLE = "ROLE"
    USER = "USER"
    MEMBER = "MEMBER"

This can still be non breaking by changing it to say...


    GLOBAL = "GLOBAL"
    GUILD = "GUILD"
    CHANNEL = "TEXTCHANNEL"  # do not change this without writing a migration.
    TEXT_CHANNEL = "ACTUALTEXTCHANNEL"
    ...

But it's a little ugly. Still worth supporting IMO, and possibly create a cleanup for this at the next version we push with actual breakage.

*sigh* after getting around to looking into this a bit more, I noticed a "fun" detail in config. ``` GLOBAL = "GLOBAL" GUILD = "GUILD" CHANNEL = "TEXTCHANNEL" ROLE = "ROLE" USER = "USER" MEMBER = "MEMBER" ``` This can still be non breaking by changing it to say... ``` GLOBAL = "GLOBAL" GUILD = "GUILD" CHANNEL = "TEXTCHANNEL" # do not change this without writing a migration. TEXT_CHANNEL = "ACTUALTEXTCHANNEL" ... ``` But it's a little ugly. Still worth supporting IMO, and possibly create a cleanup for this at the next version we push with actual breakage.
mikeshardmind commented 2019-05-17 04:49:47 +02:00 (Migrated from github.com)

Actually, because of how global scopes work (curses at getattr), this isn't non-breaking no matter what. Slate this for 3.2

Actually, because of how global scopes work (*curses at getattr*), this isn't non-breaking no matter what. Slate this for 3.2
Tobotimus commented 2019-05-17 04:56:40 +02:00 (Migrated from github.com)

I think the minimum breakage (what @mikeshardmind is saying) is that new scopes mean more functions on the Config objects, which would cause problems for cog creators who use a Global key which has the same name as the new function.

If we did it like this:

  • Config.channel which uses the ConfigCategory.CHANNEL = "TEXTCHANNEL" category,
  • Config.text_channel which uses the ConfigCategory.TEXT_CHANNEL = "ACTUALTEXTCHANNEL" category, and
  • Config.voice_channel which uses the ConfigCategory.VOICE_CHANNEL = "VOICECHANNEL" category

It's ugly, but it's unlikely to bother many cog devs. Perhaps we could look into migrating "TEXTCHANNEL" to "CHANNEL" silently to mitigate the ugliness.

Edit: I forgot about category channels but you get the picture ;)

I think the minimum breakage (what @mikeshardmind is saying) is that new scopes mean more functions on the Config objects, which would cause problems for cog creators who use a Global key which has the same name as the new function. If we did it like this: - `Config.channel` which uses the `ConfigCategory.CHANNEL = "TEXTCHANNEL"` category, - `Config.text_channel` which uses the `ConfigCategory.TEXT_CHANNEL = "ACTUALTEXTCHANNEL"` category, and - `Config.voice_channel` which uses the `ConfigCategory.VOICE_CHANNEL = "VOICECHANNEL"` category It's ugly, but it's unlikely to bother many cog devs. Perhaps we could look into migrating "TEXTCHANNEL" to "CHANNEL" silently to mitigate the ugliness. *Edit:* I forgot about category channels but you get the picture ;)
mikeshardmind commented 2019-05-17 04:59:34 +02:00 (Migrated from github.com)

I think I'd prefer deprecating global key use to prevent this sort of issue from being reoccuring (Named custom groups with 0 identifiers will work identically well) or changing how global keys are accessed config.get_global or something else like that.

But yes, that would be the breakage.

I think I'd prefer deprecating global key use to prevent this sort of issue from being reoccuring (Named custom groups with 0 identifiers will work identically well) or changing how global keys are accessed `config.get_global` or something else like that. But yes, that would be the breakage.
mikeshardmind commented 2020-01-04 05:06:45 +01:00 (Migrated from github.com)

closing this, it's rehashed in the config2 discussion better than here.

closing this, it's rehashed in the config2 discussion better than here.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#2248
No description provided.