From 299c907aba7c79b014554993e9160ec82ecbe5da Mon Sep 17 00:00:00 2001 From: romangraef Date: Mon, 26 Nov 2018 22:29:05 +0100 Subject: awaiter fix --- README.md | 8 +++++++- drutils/awaiter.py | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8f0b56d..beb05ae 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ ## Romans discord.py utilities -Yes thats it. +### Awaiter +the `drutils.awaiter` module contains a bunch of nice utils to await a message containing datatypes like roles, channels, etc. + +### Eval +a very nice eval + + diff --git a/drutils/awaiter.py b/drutils/awaiter.py index bad7c79..5e490e0 100644 --- a/drutils/awaiter.py +++ b/drutils/awaiter.py @@ -182,16 +182,19 @@ class AdvancedAwaiter: emoji = await self.emoji_choice(text, [YES_REACTION, NO_REACTION]) return emoji == YES_REACTION - async def text(self, text: str): + async def text(self, text: str) -> str: return (await self(text)).content - async def guild_channel(self, text: str, check=lambda channel: True, writable=False) -> object: + async def guild_channel(self, text: str, check=lambda channel: True, writable=False) -> TextChannel: async def converter(mes: Message): return discord.utils.get(self.guild.channels, id=int(mes.content.translate(digit_keeper))) + if not self.guild: + raise ValueError("This can only be used in guilds") + async def all_checks(channel: TextChannel): - if writable and not channel.permissions_for(self.bot.user).send_messages: + if writable and channel.guild == self.guild and not channel.permissions_for(channel.guild.me).send_messages: return False return await await_if(check, channel) -- cgit