I'm trying to implement slash_commands in my python for discord, didn't had any trouble for usual prefix command but this seems tricky and I don't know what to do? This is my code:
my cog:
import nextcord
from nextcord import Interaction
from nextcord.ext import commands
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@nextcord.slash_command(name="test", description="test", guild_ids=[GUILD_ID])
async def test(self, interaction: Interaction):
await interaction.response.send_message("hello")
def setup(client):
client.add_cog(Ping(client))
my main:
import nextcord
def main():
intents = nextcord.Intents.default()
intents.members = True
intents.message_content = True
client = commands.Bot(command_prefix=PREFIX, intents=intents)
# ---------------------------------------------------------------------------
@client.event
async def on_ready():
for folder in os.listdir("data"):
if os.path.exists(os.path.join("data", folder, "cog.py")):
client.load_extension(f"data.{folder}.cog")
client.run(BOT_TOKEN)
if __name__ == "__main__":
main()
I give discord bot Privileged Gateway Intents on developer portal, invited him as bot- administrator with applications-commands previlege. Still nothing :(
In code intents.members = True intents.message_content = True
It says that : Intents' object attribute 'members' is read-only, but I really don't know what to do next. I hope u will resolve my problem