Added "/admin say" command.

This commit is contained in:
Uwe Pfeifer 2023-03-04 13:48:09 +01:00
parent 8abc27bc3a
commit 98a0d82169
3 changed files with 13 additions and 3 deletions

2
.idea/misc.xml generated
View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pybot-f)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pybot-f)" project-jdk-type="Python SDK" />
</project> </project>

2
.idea/pybot-f.iml generated
View file

@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/botdev" /> <excludeFolder url="file://$MODULE_DIR$/botdev" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.11 (pybot-f)" jdkType="Python SDK" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View file

@ -12,12 +12,22 @@ class AdminExt(commands.GroupCog, name="admin"):
self.bot = bot self.bot = bot
super().__init__() # this is now required in this context. super().__init__() # this is now required in this context.
@app_commands.command(name="stop", description="Stops (shuts down) the bot") @app_commands.command(name="stop", description="Stops (shuts down) the bot")
@commands.is_owner() @commands.is_owner()
async def admin_stop(self, interaction: discord.Interaction) -> None: async def admin_stop(self, interaction: discord.Interaction) -> None:
""" /admin stop """ """ /admin stop """
await interaction.response.send_message("The bot will now shutdown. Good bye! :)", ephemeral=True) await interaction.response.send_message("The bot will now shutdown. Good bye! :)")
await self.bot.close() await self.bot.close()
@app_commands.command(name="say", description="Makes the bot repeat what you type")
@app_commands.describe(text="Text to send to the channel/query.")
@commands.is_owner()
async def admin_say(self, interaction: discord.Interaction, text: str) -> None:
""" /admin say <text> """
await interaction.response.send_message(text)
async def setup(bot: commands.Bot) -> None: async def setup(bot: commands.Bot) -> None:
await bot.add_cog(AdminExt(bot)) await bot.add_cog(AdminExt(bot))