fix(pterodactyl): fixed a few double pings

This commit is contained in:
Seaswimmer 2024-03-13 01:48:17 -04:00
parent 7a75266b01
commit d6bccf20e9
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -60,7 +60,7 @@ class Pterodactyl(commands.Cog):
async def on_message_without_command(self, message: discord.Message) -> None: async def on_message_without_command(self, message: discord.Message) -> None:
if message.channel.id == await config.console_channel() and message.author.bot is False: if message.channel.id == await config.console_channel() and message.author.bot is False:
logger.debug("Received console command from %s: %s", message.author.id, message.content) logger.debug("Received console command from %s: %s", message.author.id, message.content)
await message.channel.send(f"Received console command from {message.author.id}: {message.content[:1900]}") await message.channel.send(f"Received console command from {message.author.id}: {message.content[:1900]}", allowed_mentions=discord.AllowedMentions.none())
try: try:
await self.websocket.send(json.dumps({"event": "send command", "args": [message.content]})) await self.websocket.send(json.dumps({"event": "send command", "args": [message.content]}))
except websockets.exceptions.ConnectionClosed as e: except websockets.exceptions.ConnectionClosed as e:
@ -72,7 +72,7 @@ class Pterodactyl(commands.Cog):
logger.debug("Received chat message from %s: %s", message.author.id, message.content) logger.debug("Received chat message from %s: %s", message.author.id, message.content)
channel = self.bot.get_channel(await config.console_channel()) channel = self.bot.get_channel(await config.console_channel())
if channel: if channel:
await channel.send(f"Received chat message from {message.author.id}: {message.content[:1900]}") await channel.send(f"Received chat message from {message.author.id}: {message.content[:1900]}", allowed_mentions=discord.AllowedMentions.none())
msg = json.dumps({"event": "send command", "args": [await self.get_chat_command(message)]}) msg = json.dumps({"event": "send command", "args": [await self.get_chat_command(message)]})
logger.debug("Sending chat message to server:\n%s", msg) logger.debug("Sending chat message to server:\n%s", msg)
try: try:
@ -148,7 +148,7 @@ class Pterodactyl(commands.Cog):
channel = self.bot.get_channel(await config.console_channel()) channel = self.bot.get_channel(await config.console_channel())
if isinstance(ctx, discord.Interaction): if isinstance(ctx, discord.Interaction):
if channel: if channel:
await channel.send(f"Received console command from {ctx.user.id}: {command[:1900]}") await channel.send(f"Received console command from {ctx.user.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
try: try:
await self.websocket.send(json.dumps({"event": "send command", "args": [command]})) await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
await ctx.response.send_message(f"Command sent to server. {box(command, 'json')}", ephemeral=True) await ctx.response.send_message(f"Command sent to server. {box(command, 'json')}", ephemeral=True)
@ -160,7 +160,7 @@ class Pterodactyl(commands.Cog):
self.task = self.get_task() self.task = self.get_task()
else: else:
if channel: if channel:
await channel.send(f"Received console command from {ctx.author.id}: {command[:1900]}") await channel.send(f"Received console command from {ctx.author.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
try: try:
await self.websocket.send(json.dumps({"event": "send command", "args": [command]})) await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
await ctx.send(f"Command sent to server. {box(command, 'json')}") await ctx.send(f"Command sent to server. {box(command, 'json')}")