async def wrapper(self, *args, **kwargs): message = _get_variable('message') if not message or self.db.db is not None: return await func(self, *args, **kwargs) else: return Response(":warning: This command cannot be used. Only read-only commands can be used while the database is unavailable", delete=10)
def load_module(self, name): if _get_variable('allow_requests'): sys.meta_path.pop(0) return __import__('requests') import_chain = tuple(self._get_import_chain(until='from .bot import MusicBot')) import_tb = self._format_import_chain(import_chain) raise HelpfulError( "You are attempting to import requests, or import a module that uses requests. " "Requests (or any module that uses requests) should not be used in this code. " "See %s for why requests is not suitable for this code." % "[https://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean]", "Don't use requests, use aiohttp instead. The api is very similar to requests " "when using session objects. [http://aiohttp.readthedocs.io/en/stable/] If " "a module you're trying to use depends on requests, see if you can find a similar " "module compatable with asyncio. If you can't find one, learn how to avoid blocking " "in coroutines. If you're new to programming, consider learning more about how " "asynchronous code and coroutines work. Blocking calls (notably HTTP requests) can take " "a long time, during which the bot is unable to do anything but wait for it. " "If you're sure you know what you're doing, simply add `allow_requests = True` above your " "import statement, that being `import requests` or whatever requests dependent module.", footnote="Import traceback (most recent call last):\n" + import_tb )
def load_module(self, name): """ TODO """ if _get_variable('allow_requests'): sys.meta_path.pop(0) return __import__('requests') import_chain = tuple( self._get_import_chain(until='from .bot import MusicBot')) import_tb = self._format_import_chain(import_chain) raise HelpfulError( "You are attempting to import requests, or import a module that uses requests. " "Requests (or any module that uses requests) should not be used in this code. " "See %s for why requests is not suitable for this code." % "[https://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean]", "Don't use requests, use aiohttp instead. The api is very similar to requests " "when using session objects. [http://aiohttp.readthedocs.io/en/stable/] If " "a module you're trying to use depends on requests, see if you can find a similar " "module compatible with asyncio. If you can't find one, learn how to avoid blocking " "in coroutines. If you're new to programming, consider learning more about how " "asynchronous code and coroutines work. Blocking calls (notably HTTP requests) can take" "a long time, during which the bot is unable to do anything but wait for it. " "If you're sure you know what you're doing, simply add `allow_requests = True` above your" "import statement, that being `import requests` or whatever requests dependent module.", footnote="Import traceback (most recent call last):\n" + import_tb)
async def wrapper(self, *args, **kwargs): message = _get_variable('message') if not message or self.config.selfbot: return await func(self, *args, **kwargs) else: return Response(":warning: This command can only be used with selfbots", delete=10)
async def wrapper(self, *args, **kwargs): # Only allow the owner to use these commands orig_msg = _get_variable('message') if not orig_msg or orig_msg.author.id == self.config.owner_id: return await func(self, *args, **kwargs) else: raise exceptions.PermissionsError("only the owner can use this command", expire_in=30)
async def wrapper(self, *args, **kwargs): # Only allow the owner to use these commands orig_msg = _get_variable('message') if not orig_msg or orig_msg.author.id == self.config.owner_id: return await func(self, *args, **kwargs) else: raise PermissionsError("Only the bot admin can use this command.", expire_in=30)
def load_module(self, name): if _get_variable('allow_requests'): sys.meta_path.pop(0) return __import__('requests') import_chain = tuple( self._get_import_chain(until='from .bot import Helix')) import_tb = self._format_import_chain(import_chain)
async def wrapper(self, *args, **kwargs): message = _get_variable('message') if not message or self.db.db is not None: return await func(self, *args, **kwargs) else: return Response( ":warning: This command cannot be used - the database is unavailable", delete=10)
async def wrapper(self, *args, **kwargs): message = _get_variable('message') if not message or self.config.selfbot: return await func(self, *args, **kwargs) else: return Response( ":warning: This command can only be used with selfbots", delete=10)
async def wrapper(self, *args, **kwargs): message = _get_variable('message') if self.bot.user.bot: owner = (await self.bot.application_info()).owner.id else: owner = self.bot.user.id if not message or message.author.id == owner: return await func(self, *args, **kwargs) else: return Response(":warning: This command cannot be used - only the bot application creator can use this command to prevent harm", delete=10)
def _get_vars(cls, func): # log.debug("Getting vars for %s", func) params = inspect.signature(func).parameters.copy() args = {} # log.debug("Got %s", params) for name, param in params.items(): # log.debug("Checking arg %s, type %s", name, param.kind) if param.kind is param.POSITIONAL_OR_KEYWORD and param.default is None: # log.debug("Using var %s", name) args[name] = _get_variable(name) # log.debug("Collected var for arg '%s': %s", name, args[name]) return args
def _get_vars(cls, func): # log.debug("Getting vars for %s", func) params = inspect.signature(func).parameters.copy() args = {} # log.debug("Got %s", params) for name, param in params.items(): # log.debug("Checking arg %s, type %s", name, param.kind) if param.kind is param.POSITIONAL_OR_KEYWORD and param.default is None: # log.debug("Using var %s", name) args[name] = _get_variable(name) # log.debug("Collected var for arg '%s': %s", name, args[name]) return args
async def wrapper(self, *args, **kwargs): message = _get_variable('message') if self.bot.user.bot: owner = (await self.bot.application_info()).owner.id else: owner = self.bot.user.id if not message or message.author.id == owner: return await func(self, *args, **kwargs) else: return Response( ":warning: This command cannot be used - only the bot application creator can use this command to prevent harm", delete=10)