https://github.com/lynn/clidpy
CLI-configured discord.py bot
https://github.com/lynn/clidpy
discord discord-py python
Last synced: about 1 month ago
JSON representation
CLI-configured discord.py bot
- Host: GitHub
- URL: https://github.com/lynn/clidpy
- Owner: lynn
- License: mit
- Created: 2022-09-01T15:52:34.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-01T19:51:28.000Z (over 2 years ago)
- Last Synced: 2025-02-14T08:17:24.754Z (3 months ago)
- Topics: discord, discord-py, python
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clidpy
[](https://pypi.org/project/clidpy/)
A simple CLI-configured Discord bot.
I make a surprising number of "single-serving" bots, so I figured this module would be useful for me.
It's kinda like `python -m http.server` but for Discord bots.
## Usage
Run `pip install clidpy`, get your `BOT_TOKEN` from [here](https://discord.com/developers/applications), and then run:
```sh
python -m clidpy $BOT_TOKEN "!" greet "f'Hello, {name}!'"
```That's it! That's the bot. Free variables in the expression are automatically turned into parameters.
Commands work both with the supplied prefix (here `!`), and as slash commands:

## A note on slash commands
**Your bot has a special command `!sync_commands` (or whatever prefix you chose) to tell Discord about the slash commands.**
You'll have to run this yourself, somewhat sparingly. There's allegedly a rate-limit on this operation but I don't know how severe it really is.
## Importing modules
You can import modules with `-i` before the token, and define multiple commands:
```sh
python -m clidpy -i num2words -i random $BOT_TOKEN "!" \
reverse "text[::-1]" \
shout "f'**{text.upper()}!!!**'" \
wp "'https://en.wikipedia.org/wiki/' + title.replace(' ', '_')" \
spell "num2words.num2words(number)" \
roll "f'Rolling a {sides}-sided die: **{random.randint(1, int(sides))}**'"
```
This includes local modules, so you can run `clidpy -i my_code` from a directory containing `my_code.py`.