Skip to content

Commit

Permalink
Merge pull request #26 from probablyjassin:fix/points
Browse files Browse the repository at this point in the history
post results to results channel
  • Loading branch information
probablyjassin authored Nov 10, 2024
2 parents 77f27c1 + e6b2e9c commit b051584
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cogs/mogi/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async def collect(self, ctx: MogiApplicationContext):
)

file = File(create_table(ctx.mogi), filename="table.png")
message = await ctx.respond(content="# Results", file=file)
message = await ctx.results_channel.send(content="# Results", file=file)

await ctx.respond("Results got posted in the results channel.")

ctx.mogi.table_message_id = message.id

Expand Down
9 changes: 1 addition & 8 deletions cogs/profiles/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from utils.data.database import db_players, db_archived

from logger import setup_logger
from config import GUILD_IDS, REGISTER_CHANNEL_ID

from bson.int64 import Int64
import time
Expand All @@ -19,20 +18,14 @@ class register(commands.Cog):
def __init__(self, bot):
self.bot: commands.Bot = bot

@commands.Cog.listener()
async def on_ready(self):
self.MAIN_GUILD = get(self.bot.guilds, id=GUILD_IDS[0])
self.REGISTER_CHANNEL = get(self.MAIN_GUILD.channels, id=REGISTER_CHANNEL_ID)

@slash_command(
name="register",
description="Register for playing in Lounge",
guild_ids=GUILD_IDS,
)
async def register(self, ctx: MogiApplicationContext):
await ctx.defer()

if ctx.channel_id != self.REGISTER_CHANNEL.id:
if ctx.channel_id != ctx.register_channel.id:
return await ctx.respond(
"You're not in the right channel for this command.", ephemeral=True
)
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
GUILD_IDS = [int(guild_id) for guild_id in os.getenv("GUILD_IDS").split(",")]

LOG_CHANNEL_ID = int(os.getenv("LOG_CHANNEL_ID"))
RESULTS_CHANNEL_ID = int(os.getenv("LOG_CHANNEL_ID"))
REGISTER_CHANNEL_ID = int(os.getenv("REGISTER_CHANNEL_ID"))

YUZU_API_URL = os.getenv("YUZU_API_URL")
Expand Down
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MONGO_URI="mongodb+srv://user:[email protected]/"
LOUNGE_DB="lounge_prod"
GUILD_IDS=1122334455667788990,1122334455667788990
LOG_CHANNEL_ID=1122334455667788990
RESULTS_CHANNEL_ID=1122334455667788990
REGISTER_CHANNEL_ID=1122334455667788990
YUZU_API_URL="my-yuzu-api.com"
YUZU_SERVER_IP=192.168.1.1
Expand Down
9 changes: 8 additions & 1 deletion models/CustomMogiContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from utils.data.mogi_manager import mogi_manager
from models.MogiModel import Mogi

from config import GUILD_IDS
from config import GUILD_IDS, RESULTS_CHANNEL_ID, REGISTER_CHANNEL_ID


class MogiApplicationContext(discord.ApplicationContext):
Expand Down Expand Up @@ -39,5 +39,12 @@ def __init__(self, *args, **kwargs):
self.main_guild: discord.Guild = get(self.bot.guilds, id=GUILD_IDS[0])
self.inmogi_role: discord.Role = get(self.main_guild.roles, name="InMogi")

self.register_channel: discord.TextChannel = get(
self.main_guild.text_channels, id=REGISTER_CHANNEL_ID
)
self.results_channel: discord.TextChannel = get(
self.main_guild.text_channels, id=RESULTS_CHANNEL_ID
)

def get_lounge_role(self, name: str) -> discord.Role:
return get(self.main_guild.roles, name=name)

0 comments on commit b051584

Please sign in to comment.