Browse Source

One step forward, checkout test

root 1 year ago
parent
commit
4131de508f
4 changed files with 47 additions and 17 deletions
  1. 17 2
      bot/commands/admin.py
  2. 26 14
      bot/commands/general.py
  3. 1 1
      bot/main.py
  4. 3 0
      bot/query/initialise_database.py

+ 17 - 2
bot/commands/admin.py

@@ -73,15 +73,30 @@ class Admin(commands.Cog):
 	)
 	@commands.is_owner()
 	#async def sync(self, ctx: commands.Context):
-	async def sync(self, ctx: commands.Context):
+	async def sync(self, ctx: commands.Context) -> None:
 		print(self.bot.tree.get_commands())
-		print(self.bot.tree.fetch_commands())
+		print(ctx.bot.tree.get_commands())
+		print(await self.bot.tree.fetch_commands())
 		guild_count = 0
 		for guild in self.bot.guilds:
 			fmt = await ctx.bot.tree.sync(guild=guild)
 			guild_count += 1
 		await ctx.send(content=f"Synced tree of {len(fmt)} commands to {guild_count}/{len(self.bot.guilds)} guilds", ephemeral=True)
 
+	@commands.command()
+	@commands.is_owner()
+	async def synca(self, ctx: commands.Context) -> None:
+		"""Sync commands"""
+		synced = await ctx.bot.tree.sync()
+		await ctx.send(f"Synced {len(synced)} commands globally")
+
+	@commands.command()
+	@commands.is_owner()
+	async def syncb(self, ctx: commands.Context) -> None:
+		"""Sync commands"""
+		synced = await self.bot.tree.sync()
+		await ctx.send(f"Synced {len(synced)} commands globally")
+
 
 async def setup(bot: commands.Bot):
 	await bot.add_cog(Admin(bot))

+ 26 - 14
bot/commands/general.py

@@ -1,5 +1,6 @@
 from discord.ext import commands
 import discord
+from discord import app_commands
 import time
 from typing import Optional
 from query.channel import get_interact
@@ -8,11 +9,6 @@ from common.logging import report
 from local_settings import OUTPUT_CHANNEL
 from common.settings import check_ignore
 
-
-async def setup(bot: commands.Bot):
-	await bot.add_cog(GeneralCommands(bot))
-
-
 class GeneralCommands(commands.Cog):
 	"""General functionality."""
 
@@ -104,20 +100,36 @@ class GeneralCommands(commands.Cog):
 		await ctx.send(f"I shall now interact with you again where my channel settings allow it.")
 		await report(self.bot, f"`{ctx.author}` has requested to be un-ignored.")
 
-	@commands.command(
-		description="Ignore status for user.",
-		brief="Check if user is ingored",
-		help="Verify if the user is being ignored."
+	@app_commands.command(
+		name="isignored1",
+		description="Echoes a message."
 	)
-	async def isignored(self, ctx: commands.Context, user: Optional[discord.User]):
+	# @commands.command(
+	# 	description="Ignore status for user.",
+	# 	brief="Check if user is ingored",
+	# 	help="Verify if the user is being ignored."
+	# )
+	async def isignored1(self, interaction: discord.Interaction, user: Optional[discord.User]):
+		print(0)
 		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
+		if await check_ignore(self.bot.pg, interaction.author):
+			print("Ignoring")
 			return
 
 		if not user:
-			user = ctx.author
+			user = interaction.author
 
 		if await is_ignored(self.bot.pg, user.id):
-			await ctx.send(f"I am ingoring `{user}`.")
+			await interaction.response.send_message(f"I am ignoring `{user}`.")
+			print(1)
 		else:
-			await ctx.send(f"I am not ignoring `{user}`.")
+			await interaction.response.send_message(f"I am not ignoring `{user}`.")
+			print(2)
+
+	@app_commands.command(name="echo1", description="Echo a message")
+	async def echo1(self, inter: discord.Interaction, message: str) -> None:
+		await inter.response.send_message(message)
+
+
+async def setup(bot: commands.Bot):
+	await bot.add_cog(GeneralCommands(bot))

+ 1 - 1
bot/main.py

@@ -9,7 +9,7 @@ def sql_db_does_not_exist():
 	quit()
 
 def sql_authentication_error():
-	logging.error("Database autentication failed. Doublecheck username & password, and if the user has been created.")
+	logging.error("Database authentication failed. Doublecheck username & password, and if the user has been created.")
 	quit()
 
 def hint_quit():  # Hint how to edit the settings and quit

+ 3 - 0
bot/query/initialise_database.py

@@ -84,3 +84,6 @@ async def init_db(pg):
     ]
     for query in queries:
         await pg.execute(query)
+
+async def check_db(pg):
+    await pg.fetchrow("SELECT id from \"user\"")