aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-07-20 09:30:26 -0700
committerGravatar MarkKoz <[email protected]>2020-07-21 10:29:28 -0700
commitb1777fb0d93ce329c7dc4120d510ebc81ede2920 (patch)
treee6bbb05eee5d733448a5011591eb12d2fb183f3d
parentUse max_units for time since join in user command instead of precision (diff)
Clean up imports
-rw-r--r--bot/utils/messages.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index 670289941..63bda877c 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -6,8 +6,7 @@ import re
from io import BytesIO
from typing import List, Optional, Sequence, Union
-from discord import Client, Colour, Embed, File, Member, Message, Reaction, TextChannel, Webhook
-from discord.abc import Snowflake
+import discord
from discord.errors import HTTPException
from discord.ext.commands import Context
@@ -17,12 +16,12 @@ log = logging.getLogger(__name__)
async def wait_for_deletion(
- message: Message,
- user_ids: Sequence[Snowflake],
+ message: discord.Message,
+ user_ids: Sequence[discord.abc.Snowflake],
deletion_emojis: Sequence[str] = (Emojis.trashcan,),
timeout: float = 60 * 5,
attach_emojis: bool = True,
- client: Optional[Client] = None
+ client: Optional[discord.Client] = None
) -> None:
"""
Wait for up to `timeout` seconds for a reaction by any of the specified `user_ids` to delete the message.
@@ -42,7 +41,7 @@ async def wait_for_deletion(
for emoji in deletion_emojis:
await message.add_reaction(emoji)
- def check(reaction: Reaction, user: Member) -> bool:
+ def check(reaction: discord.Reaction, user: discord.Member) -> bool:
"""Check that the deletion emoji is reacted by the appropriate user."""
return (
reaction.message.id == message.id
@@ -56,8 +55,8 @@ async def wait_for_deletion(
async def send_attachments(
- message: Message,
- destination: Union[TextChannel, Webhook],
+ message: discord.Message,
+ destination: Union[discord.TextChannel, discord.Webhook],
link_large: bool = True
) -> List[str]:
"""
@@ -81,9 +80,9 @@ async def send_attachments(
if attachment.size <= destination.guild.filesize_limit - 512:
with BytesIO() as file:
await attachment.save(file, use_cached=True)
- attachment_file = File(file, filename=attachment.filename)
+ attachment_file = discord.File(file, filename=attachment.filename)
- if isinstance(destination, TextChannel):
+ if isinstance(destination, discord.TextChannel):
msg = await destination.send(file=attachment_file)
urls.append(msg.attachments[0].url)
else:
@@ -104,10 +103,10 @@ async def send_attachments(
if link_large and large:
desc = "\n".join(f"[{attachment.filename}]({attachment.url})" for attachment in large)
- embed = Embed(description=desc)
+ embed = discord.Embed(description=desc)
embed.set_footer(text="Attachments exceed upload size limit.")
- if isinstance(destination, TextChannel):
+ if isinstance(destination, discord.TextChannel):
await destination.send(embed=embed)
else:
await destination.send(
@@ -138,8 +137,8 @@ def sub_clyde(username: Optional[str]) -> Optional[str]:
async def send_denial(ctx: Context, reason: str) -> None:
"""Send an embed denying the user with the given reason."""
- embed = Embed()
- embed.colour = Colour.red()
+ embed = discord.Embed()
+ embed.colour = discord.Colour.red()
embed.title = random.choice(NEGATIVE_REPLIES)
embed.description = reason