Extend commands
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from asyncio import sleep
|
||||
from typing import List
|
||||
|
||||
import disnake
|
||||
from disnake import Option, OptionType
|
||||
from disnake import Option, OptionType, OptionChoice
|
||||
|
||||
from disnake.ext import commands, tasks
|
||||
|
||||
@@ -76,7 +77,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def set_guest_role(self, inter, role):
|
||||
await write_json(inter.guild.id, "guest_role", role.id)
|
||||
await inter.response.send_message(f"Setted up dsss bot role to: `{role.name}`", ephemeral=True)
|
||||
await inter.response.send_message(f"Set up bot role to: `{role.name}`", ephemeral=True)
|
||||
|
||||
@commands.command(name="set_prefix")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@@ -121,7 +122,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def set_bot_role(self, ctx, role):
|
||||
await write_json(ctx.guild.id, "bot_role", role.id)
|
||||
await ctx.send(f"Setted up bot role to: `{role.name}`", ephemeral=True)
|
||||
await ctx.send(f"Set up bot role to: `{role.name}`", ephemeral=True)
|
||||
|
||||
@set_bot_role.error
|
||||
@set_trigger_role.error
|
||||
@@ -146,14 +147,27 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.slash_command(
|
||||
name="set_bot_channel",
|
||||
description="Set channel whitch itterate with bot",
|
||||
description="Set channel which iterate with bot",
|
||||
options=[
|
||||
Option("channel", "specify channel", OptionType.channel, required=True),
|
||||
Option("channel", "specify channel", OptionType.string, required=True),
|
||||
]
|
||||
)
|
||||
async def set_bot_channel(self, inter, channel):
|
||||
print(type(inter.guild.text_channels))
|
||||
await write_json(inter.guild.id, "channel", channel.id)
|
||||
await inter.response.send_message(f"Channel setted up to {channel.mention}", ephemeral=True)
|
||||
await inter.response.send_message(f"Channel set up to {channel.mention}", ephemeral=True)
|
||||
|
||||
@set_bot_channel.autocomplete('channel')
|
||||
async def _list_text_channels(self,
|
||||
inter: disnake.ApplicationCommandInteraction,
|
||||
current: str) -> List[OptionChoice]:
|
||||
_list = []
|
||||
for _channel in inter.guild.text_channels:
|
||||
_list.append(_channel)
|
||||
return [
|
||||
OptionChoice(name=choice, value=choice)
|
||||
for choice in _list if current in choice
|
||||
]
|
||||
|
||||
|
||||
def setup(bot): # an extension must have a setup function
|
||||
|
||||
Reference in New Issue
Block a user