Skip to content

Commit 15900b2

Browse files
AmbratolmAmbratolm
authored andcommitted
Added AI Auto-Incentive BG-Task
1 parent eae1d66 commit 15900b2

File tree

8 files changed

+297
-155
lines changed

8 files changed

+297
-155
lines changed

api/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def lifespan(self: ActApi):
2727
log.success(
2828
f"🦄 API server connected at {self.address.hostname}:{self.address.port}."
2929
)
30-
log.info("\n" + self.info_text)
30+
# log.info("\n" + self.info_text)
3131
except Exception as e:
3232
log.error(e)
3333
yield

bot/cogs/ai_cog.py

Lines changed: 275 additions & 139 deletions
Large diffs are not rendered by default.

bot/cogs/console_cog.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def __init__(self, bot: ActBot):
1919
@app_commands.default_permissions(administrator=True)
2020
@app_commands.checks.has_permissions(administrator=True)
2121
@app_commands.command(description="Synchronize commands")
22-
async def sync(self, interaction: Interaction):
23-
count = await self.bot.sync_commands()
24-
await interaction.response.send_message(
22+
async def sync(self, interaction: Interaction, global_sync: bool = True):
23+
await interaction.response.defer(ephemeral=True)
24+
count = await self.bot.sync_commands(None if global_sync else interaction.guild)
25+
await interaction.followup.send(
2526
embed=EmbedX.success(
2627
title="Commands Synchronization",
2728
description=f"{count[0]}/{count[1]} commands synchronized.",

bot/cogs/gift_cog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def __init__(self, bot: ActBot):
2020
# ----------------------------------------------------------------------------------------------------
2121
@app_commands.guild_only()
2222
@app_commands.command(description="Give your gold to another member")
23+
@app_commands.describe(
24+
member="Member to donate gold to", gold="Amount of gold to donate"
25+
)
2326
async def donate(self, interaction: Interaction, member: Member, gold: int):
2427
# Validate input
2528
if gold <= 0:

bot/cogs/help_cog.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
# ----------------------------------------------------------------------------------------------------
1111
# * Help Cog
1212
# ----------------------------------------------------------------------------------------------------
13-
class HelpCog(
14-
GroupCog, name="help", description="Provides help and information interface."
15-
):
13+
class HelpCog(Cog, description="Provides help and information interface."):
1614
def __init__(self, bot: ActBot):
1715
self.bot = bot
1816

1917
# ----------------------------------------------------------------------------------------------------
2018
# * Commands
2119
# ----------------------------------------------------------------------------------------------------
2220
@app_commands.command(description="View all commands")
23-
async def commands(self, interaction: Interaction):
21+
async def help(self, interaction: Interaction):
2422
all_cmds = self.bot.tree.get_commands()
2523
embed = Embed(
2624
title=f"🤖 {self.bot.title} v{self.bot.version}",

bot/main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pathlib
22

3+
import discord
34
from colorama import Fore
45
from discord import (
56
Color,
@@ -8,6 +9,7 @@
89
Interaction,
910
Member,
1011
Message,
12+
Object,
1113
Permissions,
1214
User,
1315
VoiceClient,
@@ -60,10 +62,10 @@ async def setup_hook(self):
6062
@Cog.listener()
6163
async def on_ready(self):
6264
log.success(f"🎮 Bot client connected as {self.user}.")
63-
log.info("\n" + self.cogs_info_text)
64-
log.info("\n" + self.app_commands_info_text)
65-
log.info("\n" + await self.app_commands_remote_info_text)
66-
log.info("\n" + self.commands_info_text)
65+
# log.info("\n" + self.cogs_info_text)
66+
# log.info("\n" + self.app_commands_info_text)
67+
# log.info("\n" + await self.app_commands_remote_info_text)
68+
# log.info("\n" + self.commands_info_text)
6769
# await self.sync_commands()
6870

6971
# ----------------------------------------------------------------------------------------------------
@@ -106,11 +108,12 @@ async def load_cogs(self):
106108
)
107109
log.success(f"{len(self.cogs)}/{len(cog_classes)} cogs loaded.")
108110

109-
async def sync_commands(self) -> tuple[int, int]:
111+
async def sync_commands(self, guild: Guild | None = None) -> tuple[int, int]:
110112
"""Sync commands and get (synced, all) commands count."""
111113
log.loading("Syncing commands...")
112-
all_cmds = self.tree.get_commands()
113-
synced_cmds = await self.tree.sync()
114+
guild_obj = Object(id=guild.id) if guild else None
115+
all_cmds = self.tree.get_commands(guild=guild_obj)
116+
synced_cmds = await self.tree.sync(guild=guild_obj)
114117
for cmd in synced_cmds:
115118
log.info(f"{cmd} command synced.")
116119
count = (len(synced_cmds), len(all_cmds))

db/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, name: str, *args, **kwargs):
4747
self._main_database = self._engine.database
4848
host, port = self._engine.client.address or ("?", "?")
4949
log.success(f"🍃 Database client connected to {host}:{port}.")
50-
log.info("\n" + self.info_text)
50+
# log.info("\n" + self.info_text)
5151

5252
@property
5353
def info_text(self):

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async def main():
6969
intents = Intents.default()
7070
intents.members = True
7171
intents.message_content = True
72+
intents.guilds = True
7273
bot = ActBot(
7374
token=bot_token or "",
7475
command_prefix="!",

0 commit comments

Comments
 (0)