A Python wrapper for the Fluxer API – a Discord-like platform. Inspired by discord.py.
Project description
fluxerpy3
A Python wrapper for the Fluxer API, inspired by discord.py's design. Fluxer is a Discord-like platform with guilds, channels, and messages.
Features
- Async/await support – Built with modern Python async/await syntax
- Easy to use – Simple and intuitive API similar to discord.py
- Type hints – Full type hint support for better IDE integration
- Gateway support – Real-time WebSocket events (MESSAGE_CREATE, GUILD_MEMBER_ADD, …)
- Rich models –
Guild,Channel,Member,Role,Message,Reaction - Error handling – Custom exceptions for different error scenarios
Installation
pip install fluxerpy3
Or install in development mode:
pip install -e .
Quick Start
import asyncio
import fluxerpy3
async def main():
async with fluxerpy3.Client(token="your_bot_token") as client:
# Get the bot user
me = await client.get_me()
print(f"Logged in as: {me.username}")
# List all guilds (servers)
guilds = await client.get_guilds()
for guild in guilds:
print(f" {guild.name} – {guild.member_count} members")
# Send a message
await client.send_message("channel_id_here", "Hello from fluxerpy3! 🚀")
asyncio.run(main())
Usage Examples
Guild & Channel Operations
# Get a specific guild
guild = await client.get_guild("guild_id")
# Get all channels in a guild
channels = await client.get_guild_channels(guild.id)
text_channels = [c for c in channels if c.is_text_channel]
# Get recent messages from a channel
messages = await client.get_channel_messages("channel_id", limit=50)
for msg in messages:
print(f"{msg.author}: {msg.content}")
# Create a new channel
new_channel = await client.create_channel(guild.id, "bot-log", topic="Bot activity log")
Message Operations
# Send a message
msg = await client.send_message("channel_id", "Hello!")
# Edit a message
edited = await client.edit_message("channel_id", msg.id, "Hello (edited)!")
# Delete a message
await client.delete_message("channel_id", msg.id)
# Convenience methods on Message objects
await msg.reply("Replying in the same channel")
await msg.edit("Updated content")
await msg.delete()
Reaction Operations
# Add a reaction
await client.add_reaction("channel_id", msg.id, "👍")
# Remove own reaction
await client.remove_reaction("channel_id", msg.id, "👍")
# Remove another user's reaction
await client.remove_reaction("channel_id", msg.id, "👍", user_id="user_id")
# Via Message object
await msg.add_reaction("🔥")
Member & Moderation Operations
# List members
members = await client.get_guild_members(guild.id, limit=100)
# Get a specific member
member = await client.get_guild_member(guild.id, "user_id")
print(f"{member.display_name} – roles: {member.roles}")
# Kick / ban / unban
await client.kick_member(guild.id, "user_id", reason="Rule violation")
await client.ban_member(guild.id, "user_id", reason="Spam", delete_message_seconds=86400)
await client.unban_member(guild.id, "user_id")
# Convenience methods on Member
await member.kick(reason="Rule violation")
await member.ban(reason="Spam")
Gateway (Real-time Events)
import asyncio
import fluxerpy3
from fluxerpy3 import Intents
async def on_message_create(data):
author = data.get("author", {})
print(f"{author.get('username')}: {data.get('content')}")
async def main():
async with fluxerpy3.Client(token="your_bot_token") as rest:
gateway_url = await rest.get_gateway_url()
gw = fluxerpy3.GatewayClient(
token="your_bot_token",
gateway_url=gateway_url,
intents=Intents.DEFAULT,
)
gw.on("MESSAGE_CREATE", on_message_create)
await gw.connect()
asyncio.run(main())
API Reference
Client
User methods:
get_me()– Get the authenticated bot userget_user(user_id)– Get a user by IDget_user_by_username(username)– Look up a user by username
Guild methods:
get_guilds()– List all guilds the bot is inget_guild(guild_id)– Get a specific guildget_guild_channels(guild_id)– List channels in a guildget_guild_members(guild_id, limit)– List membersget_guild_member(guild_id, user_id)– Get a specific memberget_guild_roles(guild_id)– List roleskick_member(guild_id, user_id, reason)– Kick a memberban_member(guild_id, user_id, reason, delete_message_seconds)– Ban a userunban_member(guild_id, user_id)– Unban a user
Channel methods:
get_channel(channel_id)– Get a channelcreate_channel(guild_id, name, channel_type, topic, parent_id, nsfw)– Create a channeldelete_channel(channel_id)– Delete a channel
Message methods:
get_channel_messages(channel_id, limit)– Fetch messagesget_message(channel_id, message_id)– Fetch one messagesend_message(channel_id, content)– Send a messageedit_message(channel_id, message_id, content)– Edit a messagedelete_message(channel_id, message_id)– Delete a message
Reaction methods:
add_reaction(channel_id, message_id, emoji)– Add a reactionremove_reaction(channel_id, message_id, emoji, user_id)– Remove a reaction
Gateway:
get_gateway_url()– Fetch WSS gateway URLcreate_gateway_client(intents)– Create aGatewayClient
Models
| Model | Key properties |
|---|---|
User |
username, discriminator, display_name, avatar_url, bot, status |
Guild |
name, icon_url, owner_id, member_count, description |
Channel |
name, type, guild_id, topic, is_text_channel, is_voice_channel, is_category |
Member |
user, nick, display_name, guild_id, roles, joined_at |
Role |
name, color, permissions, position, mentionable, hoist |
Message |
content, channel_id, guild_id, author, member, created_at, reactions, attachments |
Reaction |
emoji, count, me |
Error Handling
from fluxerpy3 import AuthenticationError, NotFoundError, RateLimitError, APIError
try:
async with fluxerpy3.Client(token="invalid") as client:
await client.get_me()
except AuthenticationError:
print("Invalid bot token")
except NotFoundError:
print("Resource not found")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except APIError as e:
print(f"API error {e.status_code}: {e}")
License
MIT License – see LICENSE file for details
Contributing
Contributions are welcome! Please open a Pull Request.
Event Handling
client = fluxerpy3.Client(token="your_token_here")
@client.event
async def on_post_created(post):
print(f"New post created: {post.content}")
async def main():
async with client:
# Creating a post will trigger the event
await client.create_post("Test post")
asyncio.run(main())
API Reference
Client
The main client class for interacting with the Fluxer API.
Methods:
get_me()- Get the currently authenticated userget_user(user_id)- Get a user by IDget_user_by_username(username)- Get a user by usernamefollow_user(user_id)- Follow a userunfollow_user(user_id)- Unfollow a userget_feed(limit)- Get the user's feedget_post(post_id)- Get a post by IDcreate_post(content, media_urls)- Create a new postdelete_post(post_id)- Delete a postlike_post(post_id)- Like a postunlike_post(post_id)- Unlike a postrepost(post_id)- Repost a postget_post_comments(post_id, limit)- Get comments on a postcreate_comment(post_id, content)- Create a commentdelete_comment(comment_id)- Delete a commentlike_comment(comment_id)- Like a commentunlike_comment(comment_id)- Unlike a comment
Models
User
Represents a Fluxer user.
Properties:
id- User IDusername- Usernamedisplay_name- Display namebio- User bioavatar_url- Avatar URLfollower_count- Number of followersfollowing_count- Number of users being followedpost_count- Number of postscreated_at- Account creation date
Methods:
follow()- Follow this userunfollow()- Unfollow this userget_posts(limit)- Get posts by this user
Post
Represents a Fluxer post.
Properties:
id- Post IDcontent- Post contentauthor_id- Author's user IDauthor- Author user objectlike_count- Number of likescomment_count- Number of commentsrepost_count- Number of repostscreated_at- Post creation datemedia_urls- List of media URLs
Methods:
like()- Like this postunlike()- Unlike this postrepost()- Repost this postdelete()- Delete this postget_comments(limit)- Get commentscomment(content)- Add a comment
Comment
Represents a comment on a post.
Properties:
id- Comment IDcontent- Comment contentauthor_id- Author's user IDauthor- Author user objectpost_id- ID of the postlike_count- Number of likescreated_at- Comment creation date
Methods:
like()- Like this commentunlike()- Unlike this commentdelete()- Delete this comment
Error Handling
import fluxerpy3
from fluxerpy3 import AuthenticationError, NotFoundError, RateLimitError
try:
async with fluxerpy3.Client(token="invalid_token") as client:
await client.get_me()
except AuthenticationError:
print("Invalid authentication token")
except NotFoundError:
print("Resource not found")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fluxerpy3-0.1.2.tar.gz.
File metadata
- Download URL: fluxerpy3-0.1.2.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28e7ab266c3517c7f55ecf13edbbe706c8898f599a3441f78f6807468bbdc417
|
|
| MD5 |
eb005bf4519fd19b41023aa286491b75
|
|
| BLAKE2b-256 |
4e7a1b82d75b717ba8ab64f0c58bac24b4d49ee158f104e953b526e4bbb86921
|
File details
Details for the file fluxerpy3-0.1.2-py3-none-any.whl.
File metadata
- Download URL: fluxerpy3-0.1.2-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
498de0a3a18f6b2da5c2181befb356925a0bb01f6499870765b2b8cbe1206bb8
|
|
| MD5 |
cab7f4e50d874faff1732c407872fd52
|
|
| BLAKE2b-256 |
d584ffff926bce2593b2883ffa28c02e094ebf7b9d7a8af8227cfc1ade836e59
|