Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit 71e75da

Browse files
authored
Merge pull request #75 from message-manager-discord/interactions
Add custom interactions handling and add confirmation buttons
2 parents 98f252f + 1bd0b22 commit 71e75da

15 files changed

+1680
-651
lines changed

Pipfile.lock

+66-76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aerich.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[aerich]
22
tortoise_orm = tortoise_config.TORTOISE_ORM
33
location = ./migrations
4+
src_folder = ./.
45

cogs/admin.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import datetime
2323
import random
2424
import string
25+
import sys
26+
import traceback
2527

2628
from math import floor
2729
from typing import TYPE_CHECKING
@@ -30,8 +32,8 @@
3032

3133
from discord.ext import commands
3234

33-
from src import Context, errors
3435
from main import Bot
36+
from src import Context, errors
3537

3638
if TYPE_CHECKING:
3739
Cog = commands.Cog[Context]
@@ -66,7 +68,12 @@ async def cog_command_error(
6668
f"Report a bug or get support from the support server at {self.bot.command_with_prefix(ctx, 'support')}\n"
6769
f"Error: {error}"
6870
)
69-
raise error
71+
print(
72+
"Ignoring exception in command {}:".format(ctx.command), file=sys.stderr
73+
)
74+
traceback.print_exception(
75+
type(error), error, error.__traceback__, file=sys.stderr
76+
)
7077

7178
@commands.command(hidden=True)
7279
async def load(self, ctx: Context, *, module: str) -> None:

cogs/component_management.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# cogs/component_management.py
2+
3+
"""
4+
Message Manager - A bot for discord
5+
Copyright (C) 2020-2021 AnotherCat
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Affero General Public License as published
9+
by the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Affero General Public License for more details.
16+
17+
You should have received a copy of the GNU Affero General Public License
18+
along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
"""
20+
21+
import logging
22+
23+
from typing import TYPE_CHECKING
24+
25+
from discord.ext import commands, tasks
26+
27+
from main import Bot
28+
from src import Context
29+
30+
if TYPE_CHECKING:
31+
Cog = commands.Cog[Context]
32+
else:
33+
Cog = commands.Cog
34+
35+
36+
class ComponentChecking(Cog):
37+
def __init__(self, bot: Bot) -> None:
38+
self.bot = bot
39+
self.check_components.start()
40+
41+
def cog_unload(self) -> None:
42+
self.check_components.cancel()
43+
44+
@tasks.loop(minutes=120)
45+
async def check_components(self) -> None:
46+
logging.debug(f"Checking component listeners: {self.bot.component_listeners}")
47+
await self.bot.clean_component_listeners()
48+
logging.debug(f"Finished checking: {self.bot.component_listeners}")
49+
50+
51+
def setup(bot: Bot) -> None:
52+
bot.add_cog(ComponentChecking(bot))
53+
print(" Listing cog!")

cogs/listing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
from discord.ext import commands, tasks
2424

25-
from src import Context, list_wrappers
2625
from main import Bot
26+
from src import Context, list_wrappers
2727

2828
if TYPE_CHECKING:
2929
Cog = commands.Cog[Context]

0 commit comments

Comments
 (0)