Uma biblioteca mais simples para a criação de comandos no Discord.py
Project description
simplecmd_discordpy
(PT-BR): Biblioteca simples para criar comandos no discord.py, ideal para iniciantes. Não visa substituir outras bibliotecas, mas oferece uma maneira fácil de configurar e organizar comandos para bots no Discord.
(ENG): A simple library to create commands for discord.py, perfect for beginners. It doesn't aim to replace other libraries, but provides an easier way to set up and organize commands for Discord bots.
Instalação
Para instalar a biblioteca, execute o seguinte comando:
pip install simplecmd_discordpy
Usage example
import simplecmd_discordpy as scmd
import discord
TOKEN = "your_token_here"
scmd.config.set(logs=True, prefix=f"$") # Adiciona as configurações necessárias
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@scmd.command("ping") # Função para criar comandos
async def ping_cmd(msg, client, *args):
if args:
await msg.channel.send(f"Pong🏓" + ''.join(args[0]), reference=msg)
else:
await msg.channel.send(f"Pong🏓", reference=msg)
@client.event
async def on_message(message):
if message.author.bot:
return
if message.author.id == client.user.id:
return
await scmd.load(message) # Carrega Todos Os Comandos
client.run(TOKEN)
Example by Folder
import discord
import simplecmd_discordpy as scmd
TOKEN = "your_token_here"
scmd.config.set(logs=True, prefix="$", folder="commands") # Adiciona as configurações necessárias
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_message(message):
if message.author.id == client.user.id:
return
await scmd.load_files(message, client) # Carrega todos os comandos por arquivo
client.run(TOKEN)
- Já no arquivo
commands/say.py
import discord
async def run(msg, client, *args):
if args:
# Se houver argumentos passados para o comando
argumento = " ".join(args) # Junta todos os argumentos em uma única string
await msg.channel.send(argumento)
else:
# Se não houver argumentos
await msg.channel.send("Você precisa mencionar alguma coisa que o bot deve falar")
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 simplecmd_discordpy-2.0.1.tar.gz.
File metadata
- Download URL: simplecmd_discordpy-2.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47a8938ff539d949304c68db2c1aa6d18e1e99bd74511c03b7f68a3ff5d0d6ed
|
|
| MD5 |
84329504fee7a4e878c3f97b175e6111
|
|
| BLAKE2b-256 |
eab02e8e8c8d77d7b741da19ad281ce4903149943767fb1acb8e931ae4497207
|
File details
Details for the file simplecmd_discordpy-2.0.1-py3-none-any.whl.
File metadata
- Download URL: simplecmd_discordpy-2.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd04dc8caad93af987c1fa54af7d16af141d77457729fed893da447775e3256
|
|
| MD5 |
dab163bdc968d562ba2d9b14db6a1967
|
|
| BLAKE2b-256 |
09484e2d3f3c0455ea47482a7ce110189794e14b57f961cb53592004bceb1726
|