aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/evergreen
diff options
context:
space:
mode:
Diffstat (limited to 'bot/seasons/evergreen')
-rw-r--r--bot/seasons/evergreen/showprojects.py35
-rw-r--r--bot/seasons/evergreen/snakes/snakes_cog.py8
-rw-r--r--bot/seasons/evergreen/snakes/utils.py11
3 files changed, 40 insertions, 14 deletions
diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py
new file mode 100644
index 00000000..d6223690
--- /dev/null
+++ b/bot/seasons/evergreen/showprojects.py
@@ -0,0 +1,35 @@
+import logging
+
+from discord.ext import commands
+
+from bot.constants import Channels
+
+log = logging.getLogger(__name__)
+
+
+class ShowProjects(commands.Cog):
+ """Cog that reacts to posts in the #show-your-projects"""
+
+ def __init__(self, bot):
+ self.bot = bot
+ self.lastPoster = 0 # Given 0 as the default last poster ID as no user can actually have 0 assigned to them
+
+ @commands.Cog.listener()
+ async def on_message(self, message):
+ """Adds reactions to posts in #show-your-projects"""
+
+ reactions = ["\U0001f44d", "\U00002764", "\U0001f440", "\U0001f389", "\U0001f680", "\U00002b50", "\U0001f6a9"]
+ if (message.channel.id == Channels.show_your_projects
+ and message.author.bot is False
+ and message.author.id != self.lastPoster):
+ for reaction in reactions:
+ await message.add_reaction(reaction)
+
+ self.lastPoster = message.author.id
+
+
+def setup(bot):
+ """Show Projects Reaction Cog"""
+
+ bot.add_cog(ShowProjects(bot))
+ log.info("ShowProjects cog loaded")
diff --git a/bot/seasons/evergreen/snakes/snakes_cog.py b/bot/seasons/evergreen/snakes/snakes_cog.py
index 6698183f..3927fab5 100644
--- a/bot/seasons/evergreen/snakes/snakes_cog.py
+++ b/bot/seasons/evergreen/snakes/snakes_cog.py
@@ -445,7 +445,7 @@ class Snakes(Cog):
@group(name='snakes', aliases=('snake',), invoke_without_command=True)
async def snakes_group(self, ctx: Context):
"""Commands from our first code jam."""
- await ctx.invoke(self.bot.get_command("help"), "snake")
+ await ctx.send_help(ctx.command)
@bot_has_permissions(manage_messages=True)
@snakes_group.command(name='antidote')
@@ -1029,12 +1029,6 @@ class Snakes(Cog):
)
await ctx.channel.send(embed=embed)
- @snakes_group.command(name='help')
- async def help_command(self, ctx: Context):
- """Invokes the help command for the Snakes Cog."""
- log.debug(f"{ctx.author} requested info about the snakes cog")
- return await ctx.invoke(self.bot.get_command("help"), "Snakes")
-
@snakes_group.command(name='snakify')
async def snakify_command(self, ctx: Context, *, message: str = None):
"""
diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py
index 0d1505f7..4899c2a2 100644
--- a/bot/seasons/evergreen/snakes/utils.py
+++ b/bot/seasons/evergreen/snakes/utils.py
@@ -8,7 +8,6 @@ from itertools import product
from pathlib import Path
from typing import List, Tuple
-import aiohttp
from PIL import Image
from PIL.ImageDraw import ImageDraw
from discord import File, Member, Reaction
@@ -469,12 +468,10 @@ class SnakeAndLaddersGame:
async def _add_player(self, user: Member):
self.players.append(user)
self.player_tiles[user.id] = 1
- avatar_url = user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE)
- async with aiohttp.ClientSession() as session:
- async with session.get(avatar_url) as res:
- avatar_bytes = await res.read()
- im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE))
- self.avatar_images[user.id] = im
+
+ avatar_bytes = await user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE).read()
+ im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE))
+ self.avatar_images[user.id] = im
async def player_join(self, user: Member):
"""