DisnakeDev / disnake

An API wrapper for Discord written in Python.
https://docs.disnake.dev
MIT License
721 stars 137 forks source link

checks doesn't work for autocompleters #597

Open helish88 opened 2 years ago

helish88 commented 2 years ago

Summary

checks doesn't work for autocompleters, they works only after I selected something from the list

Reproduction Steps

I run the command image

Minimal Reproducible Code

import disnake
from disnake.ext import commands

LANGUAGES = ["python", "javascript", "typescript", "java", "rust", "lisp", "elixir"]

def test_check():
    async def predicate(inter: disnake.ApplicationCommandInteraction):
        if inter.user.id == 177494227918389249:
            return True
        return False

    return commands.check(predicate)  # type: ignore

class DisnakeIssue(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command()
    @commands.has_permissions(manage_guild=True)
    @test_check()
    async def languages(
        self, inter: disnake.ApplicationCommandInteraction, language: str
    ):
        pass

    @languages.autocomplete("language")
    async def language_autocomp(
        self, inter: disnake.ApplicationCommandInteraction, string: str
    ):
        string = string.lower()
        return [lang for lang in LANGUAGES if string in lang.lower()]

def setup(bot):
    bot.add_cog(DisnakeIssue(bot))
    print("DisnakeIssue is loaded.")

Expected Results

I should get error before I select something from this list, before I ran the command

Actual Results

I get an error only after I select something from the list

Intents

disnake.Intents.all()

System Information

- Python v3.8.10-final                                                                                                                                                                                             - disnake v2.5.1-final                                                                                                                                                                                                 - disnake pkg_resources: v2.5.1                                                                                                                                                                                - aiohttp v3.7.4.post0                                                                                                                                                                                             - system info: Windows 10 10.0.17763

Checklist

Additional Context

https://discord.com/channels/808030843078836254/883342278280745030/984787279530848307

onerandomusername commented 2 months ago

Confirmed this is a bug, thanks for reporting!

helish88 commented 2 months ago

After 2 years? Really? Omg 😂😂😂😂😂