Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cache_summary = f"{len(self.bot.guilds)} guild(s) and {len(self.bot.users)} user(s)"
if isinstance(self.bot, discord.AutoShardedClient):
summary.append(f"This bot is automatically sharded and can see {cache_summary}.")
elif self.bot.shard_count:
summary.append(f"This bot is manually sharded and can see {cache_summary}.")
else:
summary.append(f"This bot is not sharded and can see {cache_summary}.")
summary.append(f"Average websocket latency: {round(self.bot.latency * 1000, 2)}ms")
await ctx.send("\n".join(summary))
class Jsk(JishakuBase, metaclass=GroupCogMeta, command_parent=jsk, command_attrs=dict(hidden=True)):
async def cog_check(self, ctx):
"""Not everyone needs access to this"""
if ctx.author.id not in (144112966176997376, 501089409379205161):
return False
return True
async def git(self, ctx, pull_push, *, message=None):
"""
Executes git statements in the system shell.
This uses the system shell as defined in $SHELL, or `/bin/bash` otherwise.
Execution can be cancelled by closing the paginator.
"""
message = message if message is not None else "Updated files."
if pull_push == "push":
shellcmd = f'sudo git add .&&sudo git commit -m "{message}"&&sudo git push'
cache_summary = f"{len(self.bot.guilds)} guild(s) and {len(self.bot.users)} user(s)"
if isinstance(self.bot, discord.AutoShardedClient):
summary.append(f"This bot is automatically sharded and can see {cache_summary}.")
elif self.bot.shard_count:
summary.append(f"This bot is manually sharded and can see {cache_summary}.")
else:
summary.append(f"This bot is not sharded and can see {cache_summary}.")
summary.append(f"Average websocket latency: {round(self.bot.latency * 1000, 2)}ms")
await ctx.send("\n".join(summary))
class Jishaku(JishakuBase, metaclass=GroupCogMeta, command_parent=jsk):
"""
The frontend subclass that mixes in to form the final Jishaku cog.
"""
def setup(bot: commands.Bot):
"""
The setup function defining the jishaku.cog and jishaku extensions.
"""
bot.add_cog(Jishaku(bot=bot))