config package¶
Module contents¶
-
class
config.
Config
(path: Optional[str])[source]¶ Bases:
object
Create config object
Basic usage:
>>> config = Config("doctest_config.toml")
- Parameters
path (str) – Path of config file
-
fields
: typing.Dict[str, BaseType] = None¶ typing.Type
[BaseType
]: Current fields
-
load
() → None[source]¶ Load config from
self.file
Basic usage:
>>> from config.config_types import factory, Int >>> config = Config("doctest_config.toml") >>> config.register("my_parameter", factory(Int)) >>> config.set({"my_parameter": 3}) >>> config.save() >>> new_config = Config("doctest_config.toml") >>> new_config.register("my_parameter", factory(Int)) >>> new_config.load() >>> new_config["my_parameter"] 3
- Returns
None
-
register
(name: str, type_: Type[BaseType]) → None[source]¶ Register option
Basic usage:
>>> from config.config_types import factory, Int >>> config = Config("doctest_config.toml") >>> config.register("my_parameter", factory(Int))
- Parameters
name (str) – Name of config parameter
type (typing.Type[BaseType]) – Type of config parameter
-
save
() → None[source]¶ Save config to
self.file
Basic usage:
>>> from config.config_types import factory, Int >>> config = Config("doctest_config.toml") >>> config.register("my_parameter", factory(Int)) >>> config.set({"my_parameter": 3}) >>> config.save()
-
set
(values: dict, no_save: bool = False) → None[source]¶ Set all parameters with values (and override old ones)
Basic usage:
>>> from config.config_types import factory, Int >>> config = Config("doctest_config.toml") >>> config.register("my_parameter", factory(Int)) >>> config.set({"my_parameter": 3}) >>> config.set({"my_parameter": 4}, no_save=True)
- Parameters
values (dict) – dict of parameters
Config types¶
Base types¶
-
config.config_types.
factory
(type: Type[config.config_types.base_type.BaseType], *args, **kwargs)[source]¶ Create a new test
type
with parameters args and kwargs- Basic usage
>>> factory(Int) <config_types.Int with parameters () {}> >>> factory(Int, min=0, max=10) <config_types.Int with parameters () {'min': 0, 'max': 10}>
- Parameters
type (Type[BaseType]) – Type to create
- Returns
New type
-
class
config.config_types.
Dict
(type_key: Type[config.config_types.base_type.BaseType], type_value: Type[config.config_types.base_type.BaseType])[source]¶ Bases:
config.config_types.base_type.BaseType
Config type for dictionnary
- Basic usage
>>> from config.config_types import factory, Int, Float >>> Dict(factory(Int), factory(Float)) <config_types.Dict<<config_types.Int with parameters () {}>: <config_types.Float with parameters () {}>> object with value None>
- Parameters
type_key (typing.Type[BaseType]) – Type of keys
type_value (typing.Type[BaseType]) – Type of values
-
check_value
(value: Dict[Any, Any]) → bool[source]¶ Check if value is good
- Basic usage
>>> from config.config_types import factory, Int, Float >>> my_dict = Dict(factory(Int), factory(Float)) >>> my_dict.check_value("ere") False >>> my_dict.check_value(23) False >>> my_dict.check_value({23:0.75}) True >>> my_dict.check_value({"er":0.75}) False >>> my_dict.check_value({34:"er"}) False
- Parameters
typing.Any] value (typing.Dict[typing.Any,) – Value to check
- Returns
True if value is correct
- Return type
-
get
() → Dict[Any, Any][source]¶ Get value
- Basic usage
>>> from config.config_types import factory, Int, Float >>> my_dict = Dict(factory(Int), factory(Float)) >>> my_dict.set({34: 0.75}) >>> my_dict.get() {34: 0.75}
- Returns
Current value
- Return type
typing.Dict[typing.Any, typing.Any]
-
load
(value: List[List[Any]]) → None[source]¶ Load value from saved data
- Basic usage
>>> from config.config_types import factory, Int, Float >>> my_dict = Dict(factory(Int), factory(Float)) >>> my_dict.load([[34, 0.75]]) >>> my_dict.get() {34: 0.75}
- Parameters
value (typing.List[typing.List[typing.Any]]) –
-
set
(value: Dict[Any, Any]) → None[source]¶ Set value
- Basic usage
>>> from config.config_types import factory, Int, Float >>> my_dict = Dict(factory(Int), factory(Float)) >>> my_dict.set({34: 0.75}) >>> my_dict.set("error") Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
typing.Any] value (typing.Dict[typing.Any,) – Value to set
-
to_save
() → List[List[Any]][source]¶ Build a serializable data to save
>>> from config.config_types import factory, Int, Float >>> my_dict = Dict(factory(Int), factory(Float)) >>> my_dict.set({34: 0.75}) >>> my_dict.to_save() [[34, 0.75]]
- Returns
Dict as list of key, value tuples
- Return type
typing.List[typing.List[typing.Any]]
-
type_key
: typing.Type[BaseType] = None¶ typing.Type
[BaseType
]: Type for key
-
type_value
: typing.Type[BaseType] = None¶ typing.Type
[BaseType
]: Type for value
-
class
config.config_types.
Float
(min: Optional[float] = None, max: Optional[float] = None)[source]¶ Bases:
config.config_types.base_type.BaseType
Base Float type for config
- Basic usage
>>> Float() <config_types.Float object with value None> >>> Float(min=0) <config_types.Float object with value None, min=0 max=None> >>> Float(max=0) <config_types.Float object with value None, min=None max=0> >>> Float(min=10, max=20) <config_types.Float object with value None, min=10 max=20>
-
check_value
(value: float) → bool[source]¶ Check if value is a correct int
Check if value is int, and if applicable, between
min
andmax
or invalues
- Basic usage
>>> positive = Float(min=0) >>> negative = Float(max=0) >>> ten_to_twenty = Float(min=10, max=20) >>> positive.check_value(0) True >>> positive.check_value(-2.143) False >>> positive.check_value(345.124) True >>> negative.check_value(0) True >>> negative.check_value(-2.1324) True >>> negative.check_value(345.124) False >>> ten_to_twenty.check_value(10) True >>> ten_to_twenty.check_value(-2.1234) False >>> ten_to_twenty.check_value(13.34) True >>> ten_to_twenty.check_value(20) True >>> ten_to_twenty.check_value(23.34) False
-
get
() → float[source]¶ Get value of parameter
- Basic usage
>>> my_float = Float() >>> my_float.set(-3/4) >>> my_float.get() -0.75
- Returns
Value of parameter
- Return type
-
load
(value: float)[source]¶ Load serialized value
>>> my_float = Float() >>> my_float.load(3/4) >>> my_float.get() 0.75
- Parameters
value (float) – Value to load
-
max
: typing.Optional[float] = None¶ Max value for parameter
-
min
: typing.Optional[float] = None¶ Min value for parameter
-
set
(value: float) → None[source]¶ Set value of parameter
- Basic usage
>>> my_float = Float(min=0) >>> my_float.set(34.324) >>> my_float.set(-34.32412) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (float) – Value to set
-
to_save
() → float[source]¶ Build a serializable object
- Basic usage
>>> my_float = Float() >>> my_float.to_save() >>> my_float.set(3/4) >>> my_float.to_save() 0.75
- Returns
Current value
- Return type
-
value
: typing.Optional[float] = None¶ Current value of parameter
-
class
config.config_types.
Int
(min: Optional[int] = None, max: Optional[int] = None, values: Optional[List[int]] = None)[source]¶ Bases:
config.config_types.base_type.BaseType
Base Int type for config
- Basic usage
>>> Int() <config_types.Int object with value None> >>> Int(min=0) <config_types.Int object with value None, min=0 max=None> >>> Int(max=0) <config_types.Int object with value None, min=None max=0> >>> Int(min=10, max=20) <config_types.Int object with value None, min=10 max=20> >>> Int(values=[2, 3, 5, 7]) <config_types.Int object with value None, values=[2, 3, 5, 7]> >>> Int(min=0, values=[3, 4, 5]) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – If min and/or max are set when using values
- Parameters
min (typing.Optional[int]) – Min value for this parameter
max (typing.Optional[int]) – Max value for this parameter
values (typing.Optional[typing.List[int]]) – This parameter can only be in one of these values (raise ValueError if min or max are set with values)
-
check_value
(value: int) → bool[source]¶ Check if value is a correct int
Check if value is int, and if applicable, between
min
andmax
or invalues
- Basic usage
>>> positive = Int(min=0) >>> negative = Int(max=0) >>> ten_to_twenty = Int(min=10, max=20) >>> prime = Int(values=[2,3,5,7]) >>> positive.check_value(0) True >>> positive.check_value(-2) False >>> positive.check_value(345) True >>> negative.check_value(0) True >>> negative.check_value(-2) True >>> negative.check_value(345) False >>> ten_to_twenty.check_value(10) True >>> ten_to_twenty.check_value(-2) False >>> ten_to_twenty.check_value(20) True >>> prime.check_value(2) True >>> prime.check_value(4) False >>> prime.check_value(5) True
- Parameters
value (int) – value to check
- Return bool
True if value is correct
-
get
() → Optional[int][source]¶ Get value of parameter
- Basic usage
>>> my_int = Int() >>> my_int.set(34) >>> my_int.get() 34
- Returns
Value of parameter
- Return type
Optional[int]
-
load
(value: int) → None[source]¶ Load serialized value
>>> my_int = Int() >>> my_int.load(34) >>> my_int.get() 34
- Parameters
value (int) – Value to load
-
set
(value: int) → None[source]¶ Set value of parameter
- Basic usage
>>> my_int = Int(min=0) >>> my_int.set(34) >>> my_int.set(-34) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (int) – Value to set
-
to_save
() → int[source]¶ Build a serializable object
- Basic usage
>>> my_int = Int() >>> my_int.to_save() >>> my_int.set(34) >>> my_int.to_save() 34
- Returns
Current value
- Return type
-
values
: typing.Optional[typing.List[int]] = None¶ typing.Optional
[typing.List
[int
]]: List of valid values for parameter
-
class
config.config_types.
List
(type_: Type[config.config_types.base_type.BaseType])[source]¶ Bases:
config.config_types.base_type.BaseType
Base List type for config
- Basic usage
>>> from config.config_types import factory, Int, Float >>> List(factory(Int)) <config_types.List of <config_types.Int with parameters () {}> objects with values []> >>> List(factory(Float)) <config_types.List of <config_types.Float with parameters () {}> objects with values []>
- Parameters
type (typing.Type[BaseType]) – Type of items
-
check_value
(value: List[Any]) → bool[source]¶ Check if value is correct
- Basic usage
>>> from config.config_types import factory, Int >>> my_list = List(factory(Int)) >>> my_list.check_value([34,]) True >>> my_list.check_value(345) False >>> my_list.check_value([345, 34, 23, 45, 34, 46, 35, 2345, 'rt']) False
- Parameters
value (typing.List[typing.Any]) – Value to check
- Returns
True if value is correct
- Return type
-
get
() → List[Any][source]¶ Get value of parameter
- Basic usage
>>> from config.config_types import factory, Int >>> my_list = List(factory(Int)) >>> my_list.set([34, ]) >>> my_list.get() [34]
- Raises
ValueError – If config is empty
- Returns
Value of parameter
- Return type
typing.List[typing.Any]
-
load
(value: List[Any]) → None[source]¶ Load serialized value
>>> from config.config_types import factory, Int >>> my_list = List(factory(Int)) >>> my_list.load([34,]) >>> my_list.get() [34]
- Parameters
value (typing.List[typing.Any]) – Value to load
-
set
(value: List[Any]) → None[source]¶ Set value of parameter
- Basic usage
>>> from config.config_types import factory, Int >>> my_list = List(factory(Int)) >>> my_list.set(34) Traceback (most recent call last): ValueError: ... >>> my_list.set([45,])
- Parameters
value (typing.List[typing.Any]) – Value to set
-
to_save
() → List[Any][source]¶ Build a serializable object
- Basic usage
>>> from config.config_types import factory, Int >>> my_list = List(factory(Int)) >>> my_list.to_save() [] >>> my_list.set([34, ]) >>> my_list.to_save() [34]
- Returns
Current value
- Return type
typing.List[typing.Any]
-
type_
: typing.Type[BaseType] = None¶ typing.Type
[BaseType
]: Type of values
-
values
: typing.List[BaseType] = None¶ typing.List
[BaseType
]: Current list of value
-
class
config.config_types.
Str
[source]¶ Bases:
config.config_types.base_type.BaseType
Base Str type for config
- Basic usage
>>> Str() <config_types.Str object with value "">
-
check_value
(value: str) → bool[source]¶ Check if value is usable as str
- Basic usage
>>> my_str = Str() >>> my_str.check_value("toto") True >>> my_str.check_value(45) True
- Parameters
value (str) – Value to test
- Returns
True if value is usable as str
-
get
() → str[source]¶ Get value of parameter
- Basic usage
>>> my_str = Str() >>> my_str.set(34) >>> print(my_str.get()) 34 >>> my_str.set("Hey") >>> print(my_str.get()) Hey
- Returns
Value of parameter
-
load
(value: str) → None[source]¶ Load value
- Basic usage
>>> my_str = Str() >>> my_str.load("34") >>> my_str.get() '34'
-
set
(value: str) → None[source]¶ Set value of parameter
- Basic usage
>>> my_str = Str() >>> my_str.set("e") >>> my_str.set(34)
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (str) – Value to set
- Returns
None
-
to_save
() → str[source]¶ Build a serializable data to save
- Basic usage
>>> my_str = Str() >>> my_str.set(34) >>> my_str.to_save() '34'
- Todo
Vérifier que l’utf8 casse pas tout
- Returns
Current string content
- Return type
-
value
: str = None¶
-
class
config.config_types.
Bool
[source]¶ Bases:
config.config_types.base_type.BaseType
Base Bool type for config
- Basic usage
>>> Bool() <config_types.Bool object with value None>
-
check_value
(value: bool) → bool[source]¶ Check if value is a correct bool
- Basic usage
>>> my_bool = Bool() >>> my_bool.check_value(0) True >>> my_bool.check_value(-2) True >>> my_bool.check_value(345) True >>> my_bool.check_value(0) True >>> my_bool.check_value(-2) True >>> my_bool.check_value(345) True >>> my_bool.check_value(10) True >>> my_bool.check_value(-2) True >>> my_bool.check_value(20) True >>> my_bool.check_value(2) True >>> my_bool.check_value(4) True >>> my_bool.check_value(5) True
-
get
() → Optional[bool][source]¶ Get value of parameter
- Basic usage
>>> my_bool = Bool() >>> my_bool.set(34) >>> my_bool.get() True
- Returns
Value of parameter
- Return type
typing.Optional[bool]
-
load
(value: bool) → None[source]¶ Load serialized value
>>> my_bool = Bool() >>> my_bool.load(True) >>> my_bool.get() True
- Parameters
value (bool) – Value to load
-
set
(value: bool) → None[source]¶ Set value of parameter
- Basic usage
>>> my_bool = Bool() >>> my_bool.set(34)
- Parameters
value (bool) – Value to set
-
class
config.config_types.
Color
[source]¶ Bases:
config.config_types.base_type.BaseType
Base Color type for config
- Basic usage
>>> Color() <config_types.Color object with value 0>
-
check_value
(value: int) → bool[source]¶ Check if value is a correct bool
Check if value is int, and if applicable, between
min
andmax
or invalues
- Basic usage
>>> my_color = Color() >>> my_color.check_value(0xFF00FF) True >>> my_color.check_value(-2) False >>> my_color.check_value(345) True >>> my_color.check_value(0xFFFFFF) True >>> my_color.check_value(0x000000) True >>> my_color.check_value(0x1000000) False
-
get
() → Optional[int][source]¶ Get value of parameter
- Basic usage
>>> my_color = Color() >>> my_color.set(34) >>> my_color.get() 34
- Returns
Value of parameter
- Return type
typing.Optional[int]
-
load
(value: int) → None[source]¶ Load serialized value
>>> my_color = Color() >>> my_color.load(True) >>> my_color.get() True
- Parameters
value (int) – Value to load
-
set
(value: int) → None[source]¶ Set value of parameter
- Basic usage
>>> my_color = Color() >>> my_color.set(34)
- Parameters
value (int) – Value to set
Discord types¶
-
class
config.config_types.discord_types.
Channel
(client: BotBase)[source]¶ Bases:
config.config_types.base_type.BaseType
Base Channel type for config.
- Parameters
client (BotBase) – Client instance
- Basic usage
>>> Channel(client) <config_types.discord_type.Channel object with value None>
-
channel_instance
: typing.Optional[discord.TextChannel] = None¶ typing.Optional
[discord.TextChannel
]: Current channel instance
-
check_value
(value: Union[int, discord.channel.TextChannel]) → bool[source]¶ Check if value is correct
If bot is not connected, always True
- Basic usage
>>> my_channel = Channel(client) >>> my_channel.check_value(invalid_id_or_channel) False >>> my_channel.check_value(valid_id_or_channel) True
- Parameters
value (Union[int, discord.TextChannel]) – Value to test
- Returns
True if channel exists
-
client
: BotBase = None¶ BotBase
: Client instance for checking
-
get
() → typing.Union[int, discord.Channel][source]¶ Get value of parameter
- Basic usage
>>> my_channel = Channel(client) >>> my_channel.set(valid_id_or_channel) >>> my_channel.get() <discord.channel.TextChannel at 0x...>
If client is not connected: >>> my_channel = Channel(client) #doctest: +SKIP >>> my_channel.set(valid_id_or_channel) #doctest: +SKIP >>> my_channel.get() #doctest: +SKIP 23411424132412
- Returns
Channel object if client is connected, else id
- Return type
Union[int, discord.Channel]
-
load
(value: typing.Union[int, discord.Channel]) → None[source]¶ Load value from config
- Basic usage
>>> my_channel = Channel(client) >>> my_channel.set(valid_id) >>> my_channel.set(invalid_id) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.TextChannel]) – value to set
-
set
(value: Union[int, discord.channel.TextChannel])[source]¶ Set value of parameter
- Basic usage
>>> my_channel = Channel(client) >>> my_channel.set(valid_id_or_channel) >>> my_channel.set(invalid_id_or_channel) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.TextChannel]) – value to set
-
class
config.config_types.discord_types.
Guild
(client: BotBase)[source]¶ Bases:
config.config_types.base_type.BaseType
Base Guild type for config.
- Parameters
client (BotBase) – Client instance
- Basic usage
>>> Guild(client) <config_types.discord_type.Guild object with value None>
-
check_value
(value: Union[int, discord.guild.Guild]) → bool[source]¶ Check if value is correct
If bot is not connected, always True
- Basic usage
>>> my_guild = Guild(client) >>> my_guild.check_value(invalid_id_or_guild) False >>> my_guild.check_value(valid_id_or_guild) True
- Parameters
value (Union[int, discord.Guild]) – Value to test
- Returns
True if guild exists
-
client
: BotBase = None¶ BotBase
: Client instance for checking
-
get
() → Union[int, discord.guild.Guild][source]¶ Get value of parameter
- Basic usage
>>> my_guild = Guild(client) >>> my_guild.set(valid_id_or_guild) >>> my_guild.get() <discord.guild.Guild at 0x...>
If client is not connected: >>> my_guild = Guild(client) #doctest: +SKIP >>> my_guild.set(valid_id_or_guild) #doctest: +SKIP >>> my_guild.get() #doctest: +SKIP 23411424132412
- Returns
Guild object if client is connected, else id
- Return type
Union[int, discord.Guild]
-
guild_instance
: typing.Optional[discord.Guild] = None¶ typing.Optional
[discord.Guild
]: Current guild instance
-
load
(value: Union[int, discord.guild.Guild]) → None[source]¶ Load value from config
- Basic usage
>>> my_guild = Guild(client) >>> my_guild.set(valid_id) >>> my_guild.set(invalid_id) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.Guild]) – value to set
-
set
(value: Union[int, discord.guild.Guild]) → None[source]¶ Set value of parameter
- Basic usage
>>> my_guild = Guild(client) >>> my_guild.set(valid_id_or_guild) >>> my_guild.set(invalid_id_or_guild) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.Guild]) – value to set
-
class
config.config_types.discord_types.
User
(client: BotBase)[source]¶ Bases:
config.config_types.base_type.BaseType
Base User type for config.
- Parameters
client (BotBase) – Client instance
- Basic usage
>>> User(client) <config_types.discord_type.User object with value None>
-
check_value
(value: Union[int, discord.user.User]) → bool[source]¶ Check if value is correct
If bot is not connected, always True
- Basic usage
>>> my_user = User(client) >>> my_user.check_value(invalid_id_or_user) False >>> my_user.check_value(valid_id_or_user) True
- Parameters
value (Union[int, discord.User]) – Value to test
- Returns
True if user exists
-
client
: BotBase = None¶ BotBase
: Client instance for checking
-
get
() → Union[int, discord.user.User][source]¶ Get value of parameter
- Basic usage
>>> my_user = User(client) >>> my_user.set(valid_id_or_user) >>> my_user.get() <discord.user.User at 0x...>
If client is not connected: >>> my_user = User(client) #doctest: +SKIP >>> my_user.set(valid_id_or_user) #doctest: +SKIP >>> my_user.get() #doctest: +SKIP 23411424132412
- Returns
User object if client is connected, else id
- Return type
Union[int, discord.User]
-
load
(value: Union[int, discord.user.User]) → None[source]¶ Load value from config
- Basic usage
>>> my_user = User(client) >>> my_user.set(valid_id) >>> my_user.set(invalid_id) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.User]) – value to set
-
set
(value: Union[int, discord.user.User]) → None[source]¶ Set value of parameter
- Basic usage
>>> my_user = User(client) >>> my_user.set(valid_id_or_user) >>> my_user.set(invalid_id_or_user) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.User]) – value to set
-
to_save
() → int[source]¶ Return id of user
- Basic usage
>>> my_user = User(client) >>> my_user.set(valid_id_or_user) >>> my_user.to_save() 123412412421
- Returns
Current id
- Return type
-
user_instance
: typing.Optional[discord.User] = None¶ typing.Optional
[discord.User
]: Current user instance
-
class
config.config_types.discord_types.
Role
(client: BotBase)[source]¶ Bases:
config.config_types.base_type.BaseType
Base Role type for config.
- Parameters
client (BotBase) – Client instance
- Basic usage
>>> Role(client) <config_types.discord_type.Role object with value None>
-
check_value
(value: Union[int, discord.role.Role]) → bool[source]¶ Check if value is correct
If bot is not connected, always True
- Basic usage
>>> my_role = Role(client) >>> my_role.check_value(invalid_id_or_role) False >>> my_role.check_value(valid_id_or_role) True
- Parameters
value (Union[int, discord.Role]) – Value to test
- Returns
True if role exists
-
client
: BotBase = None¶ BotBase
: Client instance for checking
-
get
() → Union[int, discord.role.Role][source]¶ Get value of parameter
- Basic usage
>>> my_role = Role(client) >>> my_role.set(valid_id_or_role) >>> my_role.get() <discord.role.Role at 0x...>
If client is not connected: >>> my_role = Role(client) #doctest: +SKIP >>> my_role.set(valid_id_or_role) #doctest: +SKIP >>> my_role.get() #doctest: +SKIP 23411424132412
- Returns
Role object if client is connected, else id
- Return type
Union[int, discord.Role]
-
load
(value: Union[int, discord.role.Role]) → None[source]¶ Load value from config
- Basic usage
>>> my_role = Role(client) >>> my_role.set(valid_id) >>> my_role.set(invalid_id) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.Role]) – value to set
-
role_instance
: typing.Optional[discord.Role] = None¶ typing.Optional
[discord.Role
]: Current role instance
-
set
(value: Union[int, discord.role.Role]) → None[source]¶ Set value of parameter
- Basic usage
>>> my_role = Role(client) >>> my_role.set(valid_id_or_role) >>> my_role.set(invalid_id_or_role) Traceback (most recent call last): ValueError: ...
- Raises
ValueError – if attempt to set invalid value
- Parameters
value (Union[int, discord.Role]) – value to set