Discord
Discord is an instant messaging, voice, and video communication platform widely used by communities of all types.
Installation and Setup
Install the langchain-discord-shikenso
package:
pip install langchain-discord-shikenso
You must provide a bot token via environment variable so the tools can authenticate with the Discord API:
export DISCORD_BOT_TOKEN="your-discord-bot-token"
If DISCORD_BOT_TOKEN
is not set, the tools will raise a ValueError
when instantiated.
Tools
Below is a snippet showing how you can read and send messages in Discord. For more details, see the documentation for Discord tools.
from langchain_discord.tools.discord_read_messages import DiscordReadMessages
from langchain_discord.tools.discord_send_messages import DiscordSendMessage
# Create tool instances
read_tool = DiscordReadMessages()
send_tool = DiscordSendMessage()
# Example: Read the last 3 messages from channel 1234567890
read_result = read_tool({"channel_id": "1234567890", "limit": 3})
print(read_result)
# Example: Send a message to channel 1234567890
send_result = send_tool({"channel_id": "1234567890", "message": "Hello from Markdown example!"})
print(send_result)