Updated localization and moved some commands
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
from typing import List
|
||||
|
||||
import disnake
|
||||
from disnake import OptionChoice
|
||||
from disnake.ext import commands
|
||||
|
||||
from lib.Comands import write_json
|
||||
from lib.Logger import logger
|
||||
|
||||
|
||||
@@ -10,6 +16,28 @@ class Fun(commands.Cog, name='Fun'):
|
||||
async def on_ready(self):
|
||||
logger.info(f'Cog {__name__.split(".")[1]} is ready!.')
|
||||
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.slash_command(
|
||||
name="set_bot_channel",
|
||||
description="Set channel which iterate with bot",
|
||||
|
||||
)
|
||||
async def set_bot_channel(self, inter: disnake.ApplicationCommandInteraction, channel: str):
|
||||
await write_json(inter.guild.id,
|
||||
"channel",
|
||||
disnake.utils.find(lambda d: d.name == channel, inter.guild.channels).id)
|
||||
await inter.response.send_message(f"Channel set up to {channel}", ephemeral=True)
|
||||
|
||||
@set_bot_channel.autocomplete('channel')
|
||||
async def _list_text_channels(self,
|
||||
inter: disnake.ApplicationCommandInteraction,
|
||||
current: str) -> List[OptionChoice]:
|
||||
_list = [r.name for r in inter.guild.text_channels]
|
||||
return [
|
||||
OptionChoice(name=choice, value=choice)
|
||||
for choice in _list if current in choice
|
||||
]
|
||||
|
||||
|
||||
def setup(bot): # an extension must have a setup function
|
||||
bot.add_cog(Fun(bot)) # adding a cog
|
||||
|
||||
Reference in New Issue
Block a user