Package: pincer
Pincer:pushpin: Links｜Join the Discord server:https://discord.gg/pincer｜The PyPI package:https://pypi.org/project/Pincer｜Our website:https://pincer.dev📝 | ReadTheDocs:https://pincer.readthedocs.io☄️ InstallationUse the following command to install Pincer into your Python environment:pipinstallpincerTo install our version with Aiohttp Speedup, use:pipinstallpincer[speed]⚙️Didn't work?Depending on your Python installation, you might need to use one of the
following:Python is not in PATHpath/to/python.exe-mpipinstallpincerPython is in PATH but pip is notpython-mpipinstallpincerUnix systems can use pip3/python3 commandspip3installpincerpython3-mpipinstallpincerUsing multiple Python versionspy-mpipinstallpincerClient base class example:frompincer.clientimportBot# Note that both `Bot` and `Client` are valid!bot=Bot("YOUR_TOKEN_HERE")bot.run()An example on theon_readyeventPincer bots are required to inherit from the Client.fromtimeimportperf_counterfrompincerimportClientmarker=perf_counter()classBot(Client):@Client.eventasyncdefon_ready():print(f"Logged in as{client.bot}after{perf_counter()-marker}seconds")client=Bot("YOUR_TOKEN_HERE")client.run()InteractionsPincer makes developing application commands intuitive and fast.fromtypingimportAnnotation# python 3.9+fromtyping_extensionsimportAnnotation# python 3.8frompincerimportClientfrompincer.commandsimportcommand,CommandArg,Descriptionfrompincer.objectsimportUserMessage,UserclassBot(Client):@Client.eventasyncdefon_ready(self)->None:...@command(description="Say something as the bot!")asyncdefsay(self,message:str):returnmessage@user_commandasyncdefuser_command(self,user:User):returnf"The user is{user}"@message_command(name="Message command")asyncdefmessage_command(self,message:UserMessage):returnf"The message read '{message.content}'"@command(description="Add two numbers!")asyncdefadd(self,first:Annotation[int,Description("The first number")],second:Annotation[int,Description("The second number")]):returnf"The addition of `{first}` and `{second}` is `{first+second}`"For more examples, you can take a look at the examples folder or check out our
bot:https://github.com/Pincer-org/Pincer-botYou can also read the interactions guide for more information:https://docs.pincer.dev/en/latest/interactions.htmlAdvanced UsageEnable the debug modeIf you want to see everything that is happening under the hood, either out of
curiosity or to get a deeper insight into the implementation of some features,
we provide debug logging!importlogginglogging.basicConfig(level=logging.DEBUG)MiddlewareThe middleware system was introduced in version0.4.0-dev. This system gives you the
freedom to create custom events and remove the already existing middleware created by
the developers. Your custom middleware directly receives the payload from
Discord. You can't do anything wrong without accessing theoverrideattribute, but if
you do access it, the Pincer team will not provide any support for weird behavior.
So, in short, only use this if you know what you're doing. An example of using
the middleware system with a customon_readyevent can be foundin our docs.
.🏷️ License© 2021 copyright PincerThis repository is licensed under the MIT License.See LICENSE for details.