Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 189 additions & 85 deletions honeycombs/honeycombs.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion honeycombs/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"honeycombs",
"Sugar honeycombs",
"fun",
"enonomy"
"economy"
],
"permissions": [
"embed_links",
Expand Down
14 changes: 10 additions & 4 deletions honeycombs/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import logging
import random
from typing import Optional

import discord
from redbot.core import bank
Expand All @@ -32,13 +33,15 @@


class JoinButton(discord.ui.Button):
def __init__(self, label: str):
def __init__(self, label: str, guild_id: int):
super().__init__(
custom_id="join_honeycombs", label=label, style=discord.ButtonStyle.blurple
custom_id=f"join_honeycombs:{guild_id}", label=label, style=discord.ButtonStyle.blurple
)

async def callback(self, interaction: discord.Interaction):
view: HoneycombView = self.view
if self.view is None or interaction.guild is None or interaction.message is None:
return
view: HoneycombView = self.view # type: ignore[assignment]
game_state = view.cog.get_game_state(view.guild)
guild_config = await view.cog.get_guild_config(view.guild)
currency_name = await bank.get_currency_name(interaction.guild)
Expand Down Expand Up @@ -97,6 +100,7 @@ def __init__(self, cog, guild):
self.cog = cog
self.guild = guild
self.player_count = 0
self.message: Optional[discord.Message] = None

self.container = discord.ui.Container(accent_color=discord.Color.blurple())
self.container.add_item(discord.ui.Separator())
Expand All @@ -105,7 +109,7 @@ def __init__(self, cog, guild):
self.game_details = discord.ui.TextDisplay("")
self.container.add_item(self.game_details)
self.container.add_item(discord.ui.Separator())
self.join_button = JoinButton(label="Enter The Game (0/456)")
self.join_button = JoinButton(label="Enter The Game (0/456)", guild_id=guild.id)
self.container.add_item(discord.ui.ActionRow(self.join_button))
self.container.add_item(discord.ui.Separator())
self.add_item(self.container)
Expand All @@ -126,6 +130,8 @@ async def on_timeout(self):
for child in self.walk_children():
if isinstance(child, discord.ui.Button):
child.disabled = True
if self.message is None:
return
try:
await self.message.edit(view=self)
except discord.HTTPException as e:
Expand Down
2 changes: 1 addition & 1 deletion messageguard/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
SOFTWARE.
"""

from typing import Final
import re
from typing import Final

# ForwardDeleter
FD_WARN_MESSAGE: Final[str] = "You are not allowed to forward message(s)."
Expand Down
18 changes: 9 additions & 9 deletions messageguard/messageguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,28 @@
SOFTWARE.
"""

import asyncio
import re
from asyncio import Lock
from collections import defaultdict
from typing import Any, Final

import discord
import asyncio
from red_commons.logging import getLogger
from redbot.core import Config, commands
from redbot.core.bot import Red

from .commands.forward import ForwardCommands
from .commands.restrict import RestrictCommands
from .commands.spoiler import SpoilerCommands
from .container import (
FD_WARN_MESSAGE,
NS_DEFAULT_WARNING,
RP_DEFAULT_MSG,
RP_DEFAULT_TITLE,
RP_URL_REGEX,
SPOILER_REGEX,
)
from .utils import (
can_moderate,
has_allowed_role,
Expand All @@ -45,14 +53,6 @@
send_restrict_warning,
send_spoiler_warning,
)
from .container import (
FD_WARN_MESSAGE,
NS_DEFAULT_WARNING,
RP_DEFAULT_MSG,
RP_DEFAULT_TITLE,
RP_URL_REGEX,
SPOILER_REGEX,
)

log = getLogger("red.maxcogs.messageguard")

Expand Down
4 changes: 4 additions & 0 deletions messageguard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

log = getLogger("red.maxcogs.messageguard.utils")


# idk why i did this but it makes the code cleaner in some places so here we are
def has_manage_messages(
channel: Union[discord.TextChannel, discord.Thread, discord.ForumChannel],
Expand Down Expand Up @@ -64,8 +65,11 @@ def log_missing_permissions(
guild.name,
guild.id,
)


# again here we are, this is just to clean up the code a bit and make it more readable in some places.


def is_forwarded_message(message: discord.Message) -> bool:
reference = message.reference
return reference is not None and reference.type == discord.MessageReferenceType.forward
Expand Down
2 changes: 1 addition & 1 deletion pokemon/pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import humanize_list

from .commands.pokeinfo import PokeinfoCommands
from .commands.tcgcard import TcgcardCommands
from .commands.whosthatpokemon import WhosThatPokemonCommands
from .commands.pokeinfo import PokeinfoCommands

log = getLogger("red.maxcogs.whosthatpokemon")

Expand Down
2 changes: 1 addition & 1 deletion technews/technews.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from redbot.core import Config, commands
from redbot.core.bot import Red

from .utils import ChannelOrThread, _can_post
from .views import NewsLayout
from .utils import _can_post, ChannelOrThread

log = getLogger("red.maxcogs.technews")

Expand Down
5 changes: 4 additions & 1 deletion technews/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
SOFTWARE.
"""

import discord
from typing import Union

import discord

# Type alias for supported destinations
ChannelOrThread = Union[discord.TextChannel, discord.Thread]


def _can_post(me: discord.Member, channel: ChannelOrThread) -> bool:
"""
Check whether the bot can send messages and embed links in the given
Expand Down
Loading