root преди 1 година
родител
ревизия
a65b554d3c
променени са 2 файла, в които са добавени 42 реда и са изтрити 57 реда
  1. 15 25
      bot/commands/admin.py
  2. 27 32
      bot/commands/general.py

+ 15 - 25
bot/commands/admin.py

@@ -49,16 +49,13 @@ class Admin(commands.Cog):
 
 	@app_commands.command(
 		name="guildsettings",
-		description="Modify channel settings via a browser",
-		#brief="Set channel specific settings via the webgui",
-		#help="Sends a single-use time based token to the webportal"
+		description="Modify guild specific settings",
 	)
-	#@commands.has_guild_permissions(administrator=True)
-	#@commands.is_owner()
+	@commands.has_guild_permissions(administrator=True)
 	async def guildsettings(self, interaction: discord.Interaction):
 
 		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
+		if await check_ignore(self.bot.pg, interaction.user):
 			return
 
 		#await ctx.send("Menus!", view=SelectView(self.bot.pg, ctx.guild.channels))
@@ -72,30 +69,23 @@ class Admin(commands.Cog):
 		help="Update the bot commands"
 	)
 	@commands.is_owner()
-	#async def sync(self, ctx: commands.Context):
 	async def sync(self, ctx: commands.Context) -> None:
-		print(self.bot.tree.get_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.command(
+		name="testsync",
+		description="Sync commands",
+		brief="Synchronise commands to this Discord",
+		help="Update the bot commands"
+	)
 	@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 testsync(self, ctx: commands.Context) -> None:
+		ctx.bot.tree.copy_global_to(guild=ctx.guild)
+		synced = await ctx.bot.tree.sync(guild=ctx.guild)
+
+		await ctx.send(content=f"Synced {len(synced)} commands to this guild", ephemeral=True)
 
 
 async def setup(bot: commands.Bot):

+ 27 - 32
bot/commands/general.py

@@ -1,18 +1,23 @@
 from discord.ext import commands
 import discord
 from discord import app_commands
-import time
+#import time
 from typing import Optional
-from query.channel import get_interact
+#from query.channel import get_interact
 from query.user import ignore_user, unignore_user, is_ignored
 from common.logging import report
-from local_settings import OUTPUT_CHANNEL
+#from local_settings import OUTPUT_CHANNEL
 from common.settings import check_ignore
 
+
+async def setup(bot: commands.Bot) -> None:
+	await bot.add_cog(GeneralCommands(bot))
+
+
 class GeneralCommands(commands.Cog):
 	"""General functionality."""
 
-	def __init__(self, bot: commands.Bot):
+	def __init__(self, bot: commands.Bot) -> None:
 		self.bot = bot
 
 	# @commands.command(
@@ -76,60 +81,50 @@ class GeneralCommands(commands.Cog):
 	# 	await self.bot.change_presence(activity=discord.Game(name=text))
 	# 	await report(self.bot, f"`{ctx.author}` has set my status to `{text}`.")
 
-	@commands.command(
+	@app_commands.command(
+		name="ignoreme",
 		description="Get ignored.",
-		brief="Ignore sender",
-		help="Will have the bot ignore the user from now on."
 	)
-	async def ignoreme(self, ctx: commands.Context):
+	async def ignoreme(self, interaction: discord.Interaction) -> None:
 		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
+		if await check_ignore(self.bot.pg, interaction.user):
 			return
 
-		await ignore_user(self.bot.pg, ctx.author.id)
-		await ctx.send(f"To revert this use the `/unignoreme` command.")
+		await ignore_user(self.bot.pg, interaction.user.id)
+		await interaction.response.send_message(f"To revert this use the `/unignoreme` command.")
 		await report(self.bot, f"`{ctx.author}` has requested to be ignored.")
 
-	@commands.command(
+	@app_commands.command(
+		name="unignoreme",
 		description="No longer get ingored.",
-		brief="Un-ignore sender",
-		help="No longer will the bot ignore the user."
 	)
-	async def unignoreme(self, ctx: commands.Context):
-		await unignore_user(self.bot.pg, ctx.author.id)
-		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.")
+	async def unignoreme(self, interaction: discord.Interaction) -> None:
+		await unignore_user(self.bot.pg, interaction.user.id)
+		await interaction.response.send_message(f"I shall now interact with you again where my channel settings allow it.")
+		await report(self.bot, f"`{interaction.user}` has requested to be un-ignored.")
 
 	@app_commands.command(
-		name="isignored1",
-		description="Echoes a message."
+		name="isignored",
+		description="Ignore status for 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)
+	async def isignored(self, interaction: discord.Interaction, user: Optional[discord.User]) -> None:
 		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, interaction.author):
-			print("Ignoring")
+		if await check_ignore(self.bot.pg, interaction.user):
 			return
 
 		if not user:
-			user = interaction.author
+			user = interaction.user
 
 		if await is_ignored(self.bot.pg, user.id):
 			await interaction.response.send_message(f"I am ignoring `{user}`.")
-			print(1)
 		else:
 			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))
+		await inter.response.send_message(message)