Skip to main content

langchain-discord

This package provides Discord tools and a toolkit for use with LangChain. It includes:

  • DiscordReadMessages: Read messages from a given Discord channel.
  • DiscordSendMessage: Send messages to a given Discord channel.
  • DiscordToolkit: A convenient toolkit that bundles these tools.

Installation

pip install -U langchain-discord

Environment Variable

Export your bot token so the tools can authenticate with the Discord API:

export DISCORD_BOT_TOKEN="your-discord-bot-token"

If this environment variable is not set, the tools will raise a ValueError when instantiated.


Usage

Direct Tool Usage

from langchain_discord.tools.discord_read_messages import DiscordReadMessages
from langchain_discord.tools.discord_send_messages import DiscordSendMessage

# Create instances of each tool
read_tool = DiscordReadMessages()
send_tool = DiscordSendMessage()

# Read the last 5 messages from channel 1234567890
read_result = read_tool({"channel_id": "1234567890", "limit": 5})
print(read_result)

# Send a message to the same channel
send_result = send_tool({"channel_id": "1234567890", "message": "Hello from Python!"})
print(send_result)

Using the Toolkit

You can also use DiscordToolkit to automatically gather both tools:

from langchain_discord.toolkits import DiscordToolkit

toolkit = DiscordToolkit()
tools = toolkit.get_tools()

# tools[0] should be DiscordReadMessages, tools[1] is DiscordSendMessage
read_tool = tools[0]
send_tool = tools[1]

# Example usage
print(read_tool({"channel_id": "1234567890", "limit": 5}))
print(send_tool({"channel_id": "1234567890", "message": "Hello from toolkit!"}))

Tests

If you have a tests folder (e.g. tests/unit_tests/), you can run them (assuming Pytest) with:

pytest --maxfail=1 --disable-warnings -q

Make sure your DISCORD_BOT_TOKEN is set or your tests are mocked so they don’t require a real token.


License

MIT License


Further Documentation

Release files for langchain-discord-shikenso 1.1.1

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

Source distribution (sdist)

Source distribution for langchain-discord-shikenso 1.1.1
File Size Uploaded
langchain_discord_shikenso-1.1.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-discord-shikenso 1.1.1
File Interpreter ABI Platform
langchain_discord_shikenso-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / langchain_discord_shikenso-1.1.1.tar.gz

Download URL langchain_discord_shikenso-1.1.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
72182dc0aef4804210f2375f3e63d7deca05c978db5be597a704f9fe40ea399e
BLAKE2b-256 checksum
How to use checksums
9866cc9a773b60cebc409eca1009f69320930f143d48b41512ef7e225314a7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.13.2 Linux/6.8.0-52-generic

Release files / langchain_discord_shikenso-1.1.1-py3-none-any.whl

Download URL langchain_discord_shikenso-1.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f200e09adda20f81ede08f9b38a809c845ff4a344b6f7ec269ab4912fbf07e4
BLAKE2b-256 checksum
How to use checksums
d32e1115b5e921657e50fa67085911f0d227d5772eddec182bab2199db8fd7b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.13.2 Linux/6.8.0-52-generic

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

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