[Core] Dispatch on_red_api_tokens_update event on api keys update (#3146)

* feat: dispatch `on_red_api_tokens_update` event on api keys update

* docs: add event reference in Shared API Keys docs

* chore(changelog): add tonwcrier entries

* fix: wrap dispatched api tokens in MappingProxyType

* docs: reflect change of type change to read-only Mapping
This commit is contained in:
jack1142
2019-11-23 22:58:35 +01:00
committed by Michael H
parent bc5c2513f6
commit f0836d7182
4 changed files with 18 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ from enum import Enum
from importlib.machinery import ModuleSpec
from pathlib import Path
from typing import Optional, Union, List, Dict, NoReturn
from types import MappingProxyType
import discord
from discord.ext.commands import when_mentioned_or
@@ -582,6 +583,7 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: d
async with self._config.custom(SHARED_API_TOKENS, service_name).all() as group:
group.update(tokens)
self.dispatch("red_api_tokens_update", service_name, MappingProxyType(group))
async def remove_shared_api_tokens(self, service_name: str, *token_names: str):
"""