Skip to main content

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:

  1. Go to the Discord Developer Portal.
  2. Create an application, then add a bot under “Bot”.
  3. Copy the token and set it as an environment variable:
export DISCORD_BOT_TOKEN='your_token_here'
  1. Under “OAuth2”, generate an invite URL with the bot scope 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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cordslite 0.2.2
File Size Uploaded Provenance Actions
cordslite-0.2.2.tar.gz 30.3 kB Without provenance Details for cordslite-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cordslite 0.2.2
File Interpreter ABI Platform Actions
cordslite-0.2.2-py3-none-any.whl Python 3 none any Details for cordslite-0.2.2-py3-none-any.whl

Total release size: 61.3 kB

Release files / cordslite-0.2.2.tar.gz

Download URL cordslite-0.2.2.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
54ca41ef24a262ee3645f518e65191c6ed8a1e78e872efc78f12aa8afbc2a201
BLAKE2b-256 checksum
How to use checksums
72f4e89252e2dc0c1d59229cb59ddcec3840087278892b7ca2fa18f7a3dfd0ae
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.2-py3-none-any.whl

Download URL cordslite-0.2.2-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
009a72c0b7e3a53cf16e04bc12bdecf5cf6ccf61fdaff39b89f9097a23ab7abf
BLAKE2b-256 checksum
How to use checksums
a3186d99a0e9dad2e4015428b1c6d6311b98a75242929a721fa07e98d78c9338
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.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page