๐ Luna-Py - Ultimate All-in-One Python Library for Discord Bots
Project description
๐ Luna-Py - Ultimate All-in-One Python Library
Luna-Py is the ultimate all-in-one Python library for Discord bots! Easy Discord bot creation, webhooks, HTTP client, TrueWallet API, and utilities - all in one package! ๐๐
โจ Features
- ๐ค Discord Bot - Easy bot creation with discord.py
- ๐จ Discord Webhooks - Simple webhook management
- ๐จ Embeds & Buttons - Beautiful message components
- ๐ HTTP Client - Powerful HTTP requests with auto-retry
- ๐ฐ TrueWallet API - Voucher redemption
- ๐ ๏ธ Utilities - Useful helper functions
- ๐ Crypto - Encoding and token generation
๐ฆ Installation
pip install luna-py
Requirements:
- Python 3.8+
- discord.py 2.3+
๐ Quick Start
Basic Discord Bot
import luna
# Create bot
bot = luna.LunaBot.create_bot(command_prefix="!")
@bot.command()
async def ping(ctx):
await ctx.reply("๐ Pong!")
@bot.command()
async def hello(ctx):
await bot.luna_reply_embed(
ctx,
title="๐ Hello!",
description=f"Hi {ctx.author.mention}!",
color=luna.LunaEmbed.BLUE
)
bot.run("YOUR_BOT_TOKEN")
Bot with Embed
import luna
bot = luna.LunaBot.create_bot()
@bot.command()
async def info(ctx):
embed = luna.LunaEmbed.create(
title="๐ Server Info",
description="Information about this server",
color=luna.LunaEmbed.DISCORD,
fields=[
{"name": "๐ฅ Members", "value": str(ctx.guild.member_count), "inline": True},
{"name": "๐
Created", "value": ctx.guild.created_at.strftime("%Y-%m-%d"), "inline": True}
],
thumbnail=str(ctx.guild.icon.url) if ctx.guild.icon else None,
footer="Powered by Luna-Py",
timestamp=True
)
await ctx.reply(embed=embed)
bot.run("YOUR_BOT_TOKEN")
Bot with Buttons
import luna
import discord
bot = luna.LunaBot.create_bot()
@bot.command()
async def menu(ctx):
embed = luna.LunaEmbed.create(
title="๐ฎ Game Menu",
description="Choose an option:",
color=luna.LunaEmbed.BLUE
)
# Create buttons
button1 = luna.LunaButton.create(
label="Play Game",
custom_id="play",
style=discord.ButtonStyle.success,
emoji="๐ฎ"
)
button2 = luna.LunaButton.create(
label="Rules",
custom_id="rules",
style=discord.ButtonStyle.primary,
emoji="๐"
)
# Create view with buttons
view = luna.LunaView(button1, button2)
await ctx.reply(embed=embed, view=view)
# Handle button clicks
@bot.event
async def on_interaction(interaction):
if interaction.type == discord.InteractionType.component:
if interaction.data['custom_id'] == 'play':
await interaction.response.send_message("๐ฎ Starting game...")
elif interaction.data['custom_id'] == 'rules':
await interaction.response.send_message("๐ Here are the rules...")
bot.run("YOUR_BOT_TOKEN")
๐ Complete Examples
Welcome Bot
import luna
bot = luna.LunaBot.create_bot()
@bot.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.channels, name="welcome")
if not channel:
return
embed = luna.LunaEmbed.create(
title="๐ Welcome!",
description=f"Welcome to the server, {member.mention}!",
color=luna.LunaEmbed.GREEN,
thumbnail=str(member.avatar.url) if member.avatar else None,
fields=[
{"name": "๐ Member Count", "value": str(member.guild.member_count), "inline": True},
{"name": "๐
Account Created", "value": member.created_at.strftime("%Y-%m-%d"), "inline": True}
],
footer="Enjoy your stay!",
timestamp=True
)
await channel.send(embed=embed)
@bot.event
async def on_ready():
print(f"โ
{bot.user} is ready!")
bot.run("YOUR_BOT_TOKEN")
TrueWallet Bot
import luna
bot = luna.LunaBot.create_bot()
@bot.command()
async def redeem(ctx, voucher_link: str, phone: str):
"""Redeem TrueWallet voucher"""
await ctx.reply("โณ Redeeming voucher...")
result = luna.LunaTrueWallet.redeem_voucher(voucher_link, phone)
if result.get("status", {}).get("code") == "SUCCESS":
embed = luna.LunaEmbed.create(
title="โ
Voucher Redeemed!",
description=result["status"]["message"],
color=luna.LunaEmbed.SUCCESS,
fields=[
{"name": "๐ฐ Amount", "value": f"{result['data']['amount']} THB", "inline": True},
{"name": "๐ฑ Phone", "value": phone, "inline": True}
],
timestamp=True
)
else:
embed = luna.LunaEmbed.create(
title="โ Redeem Failed",
description=result.get("status", {}).get("message", "Unknown error"),
color=luna.LunaEmbed.ERROR,
timestamp=True
)
await ctx.reply(embed=embed)
bot.run("YOUR_BOT_TOKEN")
Shop Bot
import luna
import discord
bot = luna.LunaBot.create_bot()
# Product catalog
products = [
{"id": "prod1", "name": "๐ฎ Robux 100", "price": 50},
{"id": "prod2", "name": "๐ Diamonds 500", "price": 100},
{"id": "prod3", "name": "โญ Premium", "price": 150},
]
@bot.command()
async def shop(ctx):
"""Display shop"""
fields = [
{"name": p["name"], "value": f"Price: {p['price']} THB", "inline": True}
for p in products
]
embed = luna.LunaEmbed.create(
title="๐๏ธ Shop",
description="Choose a product to buy:",
color=luna.LunaEmbed.BLUE,
fields=fields
)
# Create buy buttons
buttons = [
luna.LunaButton.create(
label=p["name"],
custom_id=f"buy_{p['id']}",
style=discord.ButtonStyle.success
)
for p in products
]
view = luna.LunaView(*buttons)
await ctx.reply(embed=embed, view=view)
@bot.event
async def on_interaction(interaction):
if interaction.type == discord.InteractionType.component:
custom_id = interaction.data['custom_id']
if custom_id.startswith('buy_'):
product_id = custom_id.replace('buy_', '')
product = next((p for p in products if p['id'] == product_id), None)
if product:
embed = luna.LunaEmbed.create(
title="โ
Purchase Successful!",
description=f"You bought: {product['name']}",
color=luna.LunaEmbed.SUCCESS,
fields=[
{"name": "๐ฐ Price", "value": f"{product['price']} THB"}
]
)
await interaction.response.send_message(embed=embed, ephemeral=True)
bot.run("YOUR_BOT_TOKEN")
๐จ Discord Embeds
Create Embeds
import luna
embed = luna.LunaEmbed.create(
title="๐ Announcement",
description="This is an important announcement!",
color=luna.LunaEmbed.DISCORD,
url="https://example.com",
author={"name": "Admin Team", "icon_url": "https://example.com/icon.png"},
fields=[
{"name": "Category", "value": "Updates", "inline": True},
{"name": "Priority", "value": "High", "inline": True}
],
thumbnail="https://example.com/thumb.png",
image="https://example.com/image.png",
footer="Announcement System",
timestamp=True
)
# Send embed
await channel.send(embed=embed)
Available Colors
luna.LunaEmbed.RED # 0xFF0000
luna.LunaEmbed.GREEN # 0x00FF00
luna.LunaEmbed.BLUE # 0x0000FF
luna.LunaEmbed.YELLOW # 0xFFFF00
luna.LunaEmbed.PURPLE # 0x800080
luna.LunaEmbed.ORANGE # 0xFFA500
luna.LunaEmbed.DISCORD # 0x5865F2
luna.LunaEmbed.SUCCESS # 0x00FF00
luna.LunaEmbed.ERROR # 0xFF0000
luna.LunaEmbed.WARNING # 0xFFFF00
luna.LunaEmbed.INFO # 0x0099FF
๐จ Discord Webhooks
import luna
# Send simple message
luna.LunaWebhook.send(
webhook_url="YOUR_WEBHOOK_URL",
content="Hello from Luna-Py! ๐",
username="My Bot",
avatar_url="https://example.com/avatar.png"
)
# Send embed
embed = luna.LunaEmbed.create(
title="Webhook Message",
description="Sent via webhook!",
color=luna.LunaEmbed.BLUE
)
luna.LunaWebhook.send_embed(
webhook_url="YOUR_WEBHOOK_URL",
embed=embed
)
๐ HTTP Client
import luna
# Create HTTP client
http = luna.LunaHTTP(timeout=30, max_retries=3)
# GET request
response = http.get("https://api.example.com/data")
print(response.json())
# POST request
response = http.post(
"https://api.example.com/users",
json={"name": "John", "email": "john@example.com"}
)
๐ฐ TrueWallet API
import luna
result = luna.LunaTrueWallet.redeem_voucher(
voucher_link="https://gift.truemoney.com/campaign/?v=xxxxx",
phone_number="0812345678"
)
if result.get("status", {}).get("code") == "SUCCESS":
print(f"โ
Received {result['data']['amount']} THB")
else:
print(f"โ Error: {result.get('status', {}).get('message')}")
๐ ๏ธ Utilities
import luna
# Sleep
luna.LunaUtils.sleep(1) # Sleep 1 second
# Async sleep
await luna.LunaUtils.async_sleep(1)
# Random
num = luna.LunaUtils.random(1, 100) # Random number 1-100
text = luna.LunaUtils.random_string(16) # Random string
# Format
formatted = luna.LunaUtils.format_number(1234567) # "1,234,567"
date = luna.LunaUtils.format_date() # "2024-11-23 14:30:00"
# List operations
chunks = luna.LunaUtils.chunk_list([1,2,3,4,5,6], 2) # [[1,2], [3,4], [5,6]]
# Timestamp
ts = luna.LunaUtils.timestamp() # Unix timestamp
๐ Crypto
import luna
# Base64 encoding
encoded = luna.LunaCrypto.base64_encode("Hello World")
decoded = luna.LunaCrypto.base64_decode(encoded)
# Generate token
token = luna.LunaCrypto.generate_token(32) # 64-char hex token
๐ API Reference
Discord Bot
LunaBot.create_bot(command_prefix, intents)- Create botLunaBot.create_client(intents)- Create clientLunaEmbed.create(**kwargs)- Create embedLunaButton.create(**kwargs)- Create buttonLunaView(*buttons, timeout)- Create view
Webhooks
LunaWebhook.send(webhook_url, **kwargs)- Send messageLunaWebhook.send_embed(webhook_url, embed, **kwargs)- Send embed
HTTP
LunaHTTP(timeout, max_retries)- Create clienthttp.get(url, **kwargs)- GET requesthttp.post(url, **kwargs)- POST requesthttp.put(url, **kwargs)- PUT requesthttp.delete(url, **kwargs)- DELETE request
TrueWallet
LunaTrueWallet.redeem_voucher(link, phone)- Redeem voucher
Utils
LunaUtils.sleep(seconds)- SleepLunaUtils.async_sleep(seconds)- Async sleepLunaUtils.random(min, max)- Random numberLunaUtils.random_string(length)- Random stringLunaUtils.format_number(num)- Format numberLunaUtils.chunk_list(lst, size)- Chunk listLunaUtils.timestamp()- Unix timestampLunaUtils.format_date(dt, format)- Format date
Crypto
LunaCrypto.base64_encode(text)- Encode base64LunaCrypto.base64_decode(encoded)- Decode base64LunaCrypto.generate_token(length)- Generate token
๐ก Getting Your Bot Token
- Go to https://discord.com/developers/applications
- Create "New Application"
- Go to "Bot" section
- Click "Reset Token" and copy it
- Enable necessary intents
- Invite bot to your server
๐ฆ Dependencies
- discord.py >= 2.3.0
- requests >= 2.31.0
- aiohttp >= 3.9.0
๐ค Contributing
Contributions welcome! Open issues or PRs on GitHub.
๐ License
MIT ยฉ Luna-Py Team
๐ Links
- PyPI: https://pypi.org/project/luna-py/
- JavaScript Version: https://www.npmjs.com/package/lunahub
Made with ๐ by Luna Team
Project details
Release history Release notifications | RSS feed
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 lunahub_py-1.0.0.tar.gz.
File metadata
- Download URL: lunahub_py-1.0.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1af800c903257c75c41f91a7d5628c67842282eeb278544eb14869a1041f4a7
|
|
| MD5 |
dfff5575c8435d4bf01b7a4fc87ec6f8
|
|
| BLAKE2b-256 |
2b75b860efc20e3bdb98e9dc4338a8ad31cdf8298d00d2b51cbc4cad48a3928f
|
File details
Details for the file lunahub_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: lunahub_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae05564eabeaba4076bf73638bde0efa6079018c82575296b7c12d920321e10
|
|
| MD5 |
e46f70678750e894c18f74afd3da94b2
|
|
| BLAKE2b-256 |
5803c2ff196b91fa7668307a6569c516461a9d9087a6eb5dab7278c2680e89a0
|