cordslite 🍺
Usage
Installation
Install latest from the GitHub repository:
$ pip install git+https://github.com/AnswerDotAI/cordslite.git
or from pypi
$ pip install cordslite
How to use
Setup
Getting a bot token:
- Go to the Discord Developer Portal.
- Create an application, then add a bot under “Bot”.
- Copy the token and set it as an environment variable:
export DISCORD_BOT_TOKEN='your_token_here'
- Under “OAuth2”, generate an invite URL with the
botscope and the permissions you need, and open it to invite the bot to your server.
Then create the client:
from cordslite import *
dc = DiscordClient()
Guilds and Channels
Fetch a guild (server) and explore its channels:
gid = '1493461895615873044'
gld = await dc.guild(gid)
gld
Guild(id=1493461895615873044, name='AAI-test-dev')
chs = await gld.channels()
chs
| ID | Name | Type |
|---|---|---|
| 1493461896139903026 | Text Channels | 4 |
| 1493461896139903027 | Voice Channels | 4 |
| 1493461896139903028 | general | 0 |
| 1493461896139903029 | General | 2 |
Messages
Fetch recent messages from a channel and send one:
ch = chs[2]
msgs = await ch.messages(5)
msgs
| ID | Author | Content | Date |
|---|---|---|---|
| 1545126723224600577 | share2self | Watch this ma! | 2026-09-03 |
| 1545127267020054540 | share2self | Hello from cordslite! 🍺 | 2026-09-03 |
| 1545127273374552074 | share2self | Watch this ma! | 2026-09-03 |
| 1545127676359082054 | share2self | Hello from cordslite! 🍺 | 2026-09-03 |
| 1545127678238003282 | share2self | Watch this ma! | 2026-09-03 |
msg = await ch.send('Hello from cordslite! 🍺')
msg
Message(id=1545128287922159727, author='share2self', content='Hello from cordslite! 🍺')
Gateway (Real-time Events)
Connect, then register handlers for events such as MESSAGE_CREATE:
intents = Intent.GUILDS | Intent.GUILD_VOICE_STATES | Intent.GUILD_MESSAGES | Intent.MESSAGE_CONTENT
gc = GatewayClient(intents, dc)
await gc.start()
async def on_msg(msg): print(f"{msg.author['username']}: {msg.content}")
gc.on('MESSAGE_CREATE', on_msg)
msg = await ch.send('Watch this ma!')
msg
Message(id=1545128289734107176, author='share2self', content='Watch this ma!')
await gc.stop()
Bot
Bot ties REST and Gateway together with a decorator-based command router. It lives in cordslite.bot, alongside the voice support, and needs the voice extra: pip install cordslite[voice]. The function name becomes the command name, prefixed with ! in Discord:
from cordslite.bot import *
bot = Bot(intents)
await bot.start()
@bot.cmd
async def echo(msg, args): await (await msg.channel).send(f'You said: {args}')
bot
Bot(cmds=['echo'])
The router catches errors in command handlers and stores them in bot.errors. You can also register a handler that runs as they happen:
@bot.on_error
async def handle_err(msg, e): print(f'Error: {e}')
import asyncio
Voice
Join a voice channel, record audio, and leave:
vch = next(c for c in await gld.channels() if c.type == 2)
vc = await bot.join_voice(vch)
await asyncio.wait_for(vc.sess.wait(), 15)
vc.start_recording(path='/tmp/recording.mp3')
voice json 15 {'any': 100}
'/tmp/recording.mp3'
await asyncio.sleep(5)
res = await vc.stop_recording()
await bot.leave_voice()
await bot.stop()
res
{'speakers': {}, 'mixed': None}
from IPython.display import Audio
Audio(res['mixed'])
Metadata
Release files for cordslite 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cordslite-0.2.0.tar.gz | 30.0 kB | Without provenance | Details for cordslite-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cordslite-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for cordslite-0.2.0-py3-none-any.whl |
Total release size: 60.8 kB
Release files / cordslite-0.2.0.tar.gz
| Download URL | cordslite-0.2.0.tar.gz |
|---|---|
| Size | 30.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd7390c02522ce7aea3855536a87d25344783e59bdace894754910436071a5d1
|
|
BLAKE2b-256 checksum How to use checksums |
7906baeb24e34ba3d345169f3ee1b435d96eb1fb2cce40e32de373da2888e644
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / cordslite-0.2.0-py3-none-any.whl
| Download URL | cordslite-0.2.0-py3-none-any.whl |
|---|---|
| Size | 30.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68c9f943d1f12ad5e712d3624398f424f9d824d172c5402704f121206a3568d7
|
|
BLAKE2b-256 checksum How to use checksums |
77cec419c94a6fff7f42d7a0c4365e1b7fe4a2115e099f40c89d3d866c207f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for cordslite 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.