Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement core tickets system #20

Merged
merged 72 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
558bb48
Implement ticket creation and user communication features
No767 Dec 10, 2023
c97f0cb
Merge changes from main into noelle/tickets
No767 Dec 10, 2023
28f8552
Cleanup code
No767 Dec 10, 2023
c00eb16
Only process closing commands in DMs
No767 Dec 10, 2023
a3c60d7
Centralize server id
No767 Dec 10, 2023
de0660f
Merge branch 'main' into noelle/tickets
No767 Dec 11, 2023
194231e
Merge branch 'main' into noelle/tickets
No767 Dec 11, 2023
7998599
Update from main
No767 Dec 12, 2023
47f9404
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2023
ffec9a3
Remove `display_message` and force a timeout msg
No767 Dec 13, 2023
afbf5a3
Implement staff notification for new tickets
No767 Dec 13, 2023
ae4aaef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 13, 2023
6685490
Delete the timeout message after 15 seconds
No767 Dec 13, 2023
b1fafff
Ensure that the correct args are passed in
No767 Dec 13, 2023
a6d300d
Add `?close` cand closing system
No767 Dec 13, 2023
83ceccb
Remove redundant returns
No767 Dec 13, 2023
9cd139a
Merge branch 'main' into noelle/tickets
No767 Dec 19, 2023
8d2e925
Include better logging embed and fix timeout issues
No767 Dec 19, 2023
bb1a389
Properly log all ticket events and cleaner `?close` cmd
No767 Dec 20, 2023
d2a45bf
Clean up utils
No767 Dec 20, 2023
e45435a
Align to best practices
No767 Dec 20, 2023
c81a414
Fix caches not invalidating properly
No767 Dec 20, 2023
ea20f8d
Merge branch 'main' into noelle/tickets
No767 Dec 28, 2023
8b97ed3
Fix ticket creation view from editing invalid messages
No767 Dec 28, 2023
633ba4e
Redo `?close` cmd and ensure that caches are invalidated properly
No767 Dec 28, 2023
c54af74
Remove dead code
No767 Dec 28, 2023
ab781ee
Remove more dead code
No767 Dec 28, 2023
231a402
Add custom ticket title support
No767 Dec 28, 2023
5023b44
Invalidate guild config cache if guild is removed
No767 Dec 28, 2023
06b4b26
Implement tag selection process
No767 Dec 29, 2023
539744d
Remove dead code
No767 Dec 29, 2023
3af705c
Apply a resolved tag for locked tickets
No767 Dec 29, 2023
af9a31c
Include cmd to determine active status of a current ticket
No767 Dec 29, 2023
bccacc7
Implement basic info commands
No767 Dec 29, 2023
3414378
Fix inproper bypass of invalid ticket caches
No767 Dec 30, 2023
61d463d
Implement `PartialConfig` to provide global guild config
No767 Dec 30, 2023
47a8a46
Remove old references of `TRANSPROGRAMMER_SERVER_ID`
No767 Dec 30, 2023
e64c268
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2023
177502e
Use type checking and future imports for parity
No767 Dec 30, 2023
02911e5
Revert on prev changes
No767 Dec 30, 2023
83545e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2023
4c1b01f
Remove presences intents
No767 Dec 30, 2023
02ec509
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2023
c6d0c91
Merge branch 'main' into noelle/tickets
No767 Dec 30, 2023
9bc7446
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2023
adee012
Document common emojis (Suggested by Mir)
No767 Jan 2, 2024
851036d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2024
f04eee2
Fix missing f-strings
No767 Jan 2, 2024
21c1dcd
Merge branch 'noelle/tickets' of https://github.com/transprogrammer/r…
No767 Jan 2, 2024
461c618
Remove unnecessary `__repr__` and testing code
No767 Jan 2, 2024
ef1684f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2024
1641e7a
Add file attachment support for tickets
No767 Jan 2, 2024
5cefed0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2024
bf19e30
Avoid sending messages in locked tickets
No767 Jan 2, 2024
30ba2b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2024
00669c0
Fix improper usage of obtaining threads and remove improper cache inv…
No767 Jan 2, 2024
8869635
Merge branch 'noelle/tickets' of https://github.com/transprogrammer/r…
No767 Jan 2, 2024
90629bb
Implement `?reply` command
No767 Jan 3, 2024
df10313
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
f2bc872
Remove cmd message for reply
No767 Jan 3, 2024
ada5652
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
f5e3539
Merge branch main into noelle/tickets
No767 Jan 3, 2024
b0276d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
1d7b8b0
Add display emoji for tickets cog
No767 Jan 3, 2024
1a16fa2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
b295b43
Merge branch 'main' into noelle/tickets
No767 Jan 3, 2024
b5e08c6
Implement delayed deletion of original reply msgs
No767 Jan 3, 2024
93f8599
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
148afda
Merge branch 'main' into noelle/tickets
No767 Jan 4, 2024
7408521
Merge main into noelle/tickets
No767 Jan 5, 2024
b7428dc
Moved dm comms cog, cleaned internally struct of Rodhaj bot
No767 Jan 5, 2024
1b0676c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 5, 2024
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
42 changes: 33 additions & 9 deletions bot/cogs/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Optional
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

import asyncpg
import discord
import msgspec
from async_lru import alru_cache
from discord.ext import commands
from libs.utils import RoboContext, is_manager
from rodhaj import Rodhaj

if TYPE_CHECKING:
from rodhaj import Rodhaj

UNKNOWN_ERROR_MESSAGE = (
"An unknown error happened. Please contact the dev team for assistance"
Expand All @@ -21,6 +25,7 @@ class GuildConfig(msgspec.Struct):
ticket_channel_id: int
logging_channel_id: int
logging_broadcast_url: str
ticket_broadcast_url: str
locked: bool = False

@property
Expand Down Expand Up @@ -54,10 +59,18 @@ async def get_webhook(self) -> Optional[discord.Webhook]:
url=conf.logging_broadcast_url, session=self.session
)

async def get_ticket_webhook(self) -> Optional[discord.Webhook]:
conf = await self.get_config()
if conf is None:
return None
return discord.Webhook.from_url(
url=conf.ticket_broadcast_url, session=self.session
)

@alru_cache()
async def get_config(self) -> Optional[GuildConfig]:
query = """
SELECT id, category_id, ticket_channel_id, logging_channel_id, logging_broadcast_url, locked
SELECT id, category_id, ticket_channel_id, logging_channel_id, logging_broadcast_url, ticket_broadcast_url, locked
FROM guild_config
WHERE id = $1;
"""
Expand Down Expand Up @@ -184,17 +197,24 @@ async def setup(self, ctx: RoboContext, *, flags: SetupFlags) -> None:
forum_description = "\n".join(forum_description_content)
forum_tags = [
discord.ForumTag(
name="Question", emoji=discord.PartialEmoji(name="\U00002753")
name="Question",
emoji=discord.PartialEmoji(
name="\U00002753"
), # U+2753 Black Question Mark Ornament
),
discord.ForumTag(
name="Serious", emoji=discord.PartialEmoji(name="\U0001f610")
name="Serious",
emoji=discord.PartialEmoji(name="\U0001f610"), # U+1F610 Neutral Face
),
discord.ForumTag(
name="Private", emoji=discord.PartialEmoji(name="\U0001f512")
name="Private",
emoji=discord.PartialEmoji(name="\U0001f512"), # U+1F512 Lock
),
discord.ForumTag(
name="Resolved",
emoji=discord.PartialEmoji(name="\U00002705"),
emoji=discord.PartialEmoji(
name="\U00002705"
), # U+2705 White Heavy Check Mark
moderated=True,
),
]
Expand Down Expand Up @@ -222,6 +242,9 @@ async def setup(self, ctx: RoboContext, *, flags: SetupFlags) -> None:
default_layout=discord.ForumLayoutType.list_view,
available_tags=forum_tags,
)
tc_webhook = await ticket_channel.create_webhook(
name="Rodhaj User Proxy Webhook", avatar=avatar_bytes
No767 marked this conversation as resolved.
Show resolved Hide resolved
)
except discord.Forbidden:
await ctx.send(
"\N{NO ENTRY SIGN} Rodhaj is missing permissions: Manage Channels and Manage Webhooks"
Expand All @@ -232,8 +255,8 @@ async def setup(self, ctx: RoboContext, *, flags: SetupFlags) -> None:
return

query = """
INSERT INTO guild_config (id, category_id, ticket_channel_id, logging_channel_id, logging_broadcast_url)
VALUES ($1, $2, $3, $4, $5);
INSERT INTO guild_config (id, category_id, ticket_channel_id, logging_channel_id, logging_broadcast_url, ticket_broadcast_url)
VALUES ($1, $2, $3, $4, $5, $6);
"""
try:
await self.pool.execute(
Expand All @@ -243,6 +266,7 @@ async def setup(self, ctx: RoboContext, *, flags: SetupFlags) -> None:
ticket_channel.id,
logging_channel.id,
lgc_webhook.url,
tc_webhook.url,
)
except asyncpg.UniqueViolationError:
await ticket_channel.delete(reason=delete_reason)
Expand Down
Loading