Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from mdiluz/follow-up-fixes
Browse files Browse the repository at this point in the history
A few follow-up fixes
  • Loading branch information
mdiluz authored Aug 16, 2024
2 parents 04e9e3a + a5d66ac commit 37e1e7a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Matchy matches matchees.

Matchy is a Discord bot that groups up users for fun and vibes. Matchy can be installed on your server by clicking [here](https://discord.com/oauth2/authorize?client_id=1270849346987884696). Matchy only allows authorised users to trigger posts in channels.
Matchy is a Discord bot that groups up users for fun and vibes. Matchy can be installed on your server by clicking [here](https://discord.com/oauth2/authorize?client_id=1270849346987884696&permissions=0&integration_type=0&scope=bot). Matchy only allows authorised users to trigger posts in channels.

![Tests](https://github.com/mdiluz/matchy/actions/workflows/test.yml/badge.svg)

Expand Down
4 changes: 2 additions & 2 deletions matchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

@bot.event
async def setup_hook():
await bot.add_cog(matchy.cogs.matchy.Cog(bot, state))
await bot.add_cog(matchy.cogs.owner.Cog(bot, state))
await bot.add_cog(matchy.cogs.matchy.MatchyCog(bot, state))
await bot.add_cog(matchy.cogs.owner.OwnerCog(bot, state))


@bot.event
Expand Down
6 changes: 3 additions & 3 deletions matchy/cogs/matchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from datetime import datetime, timedelta, time

import matchy.views.match as match
import matching
import matchy.matching as matching
from matchy.files.state import State, AuthScope
import util
import matchy.util as util

logger = logging.getLogger("cog")
logger.setLevel(logging.INFO)


class Cog(commands.Cog):
class MatchyCog(commands.Cog):
def __init__(self, bot: commands.Bot, state: State):
self.bot = bot
self.state = state
Expand Down
2 changes: 1 addition & 1 deletion matchy/cogs/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
logger.setLevel(logging.INFO)


class Cog(commands.Cog):
class OwnerCog(commands.Cog):
def __init__(self, bot: commands.Bot, state: State):
self._bot = bot
self._state = state
Expand Down
8 changes: 7 additions & 1 deletion matchy/files/ops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""File operation helpers"""
import json
import shutil
import pathlib
import os


def load(file: str) -> dict:
Expand All @@ -12,8 +14,12 @@ def load(file: str) -> dict:
def save(file: str, content: dict):
"""
Save out a content dictionary to a file
Stores it in an intermediary file first incase the dump fails
"""
# Ensure the save directory exists first
dir = pathlib.Path(os.path.dirname(file))
dir.mkdir(parents=True, exist_ok=True)

# Store in an intermediary directory first
intermediate = file + ".nxt"
with open(intermediate, "w") as f:
json.dump(content, f, indent=4)
Expand Down
2 changes: 1 addition & 1 deletion matchy/views/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re

import matchy.files.state as state
import matching
import matchy.matching as matching

logger = logging.getLogger("match_button")
logger.setLevel(logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions tests/owner_cog_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import matchy.files.state as state
import discord.ext.test as dpytest

from matchy.cogs.owner import Cog
from matchy.cogs.owner import OwnerCog

# Primarily borrowing from https://dpytest.readthedocs.io/en/latest/tutorials/using_pytest.html
# TODO: Test more somehow, though it seems like dpytest is pretty incomplete
Expand All @@ -20,7 +20,7 @@ async def bot():
b = commands.Bot(command_prefix="$",
intents=intents)
await b._async_setup_hook()
await b.add_cog(Cog(b, state.State(state._EMPTY_DICT)))
await b.add_cog(OwnerCog(b, state.State(state._EMPTY_DICT)))
dpytest.configure(b)
yield b
await dpytest.empty_queue()
Expand Down

0 comments on commit 37e1e7a

Please sign in to comment.