### Estrutura Inicial do Bot
# main.py
import discord
from discord.ext import commands
import json
import asyncio
import os
with open("config.json") as f:
config = json.load(f)
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="/", intents=intents)
@bot.event
async def on_ready():
print(f"[Online] Bot conectado como {bot.user}.")
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
print("[OK] Cogs carregadas com sucesso.")
bot.run(config["token"])
# config.json
{
"token": "SEU_TOKEN_AQUI",
"guild_id": 1234567890,
"verification_channel_id": 1234567890,
"verified_role_id": 1234567890,
"ticket_category_id": 1234567890,
"staff_role_id": 1234567890,
"log_channel_id": 1234567890
}
# cogs/__init__.py
# (deixe vazio para marcar como pacote Python)
# cogs/verification.py
import discord
from discord.ext import commands
from discord.ui import View, Button
class VerificationView(View):
def __init__(self, role_id):
super().__init__(timeout=None)
self.role_id = role_id
@discord.ui.button(label="✅ Verificar", style=discord.ButtonStyle.success,
custom_id="verificar")
async def verify_button(self, interaction: discord.Interaction, button:
discord.ui.Button):
role = interaction.guild.get_role(self.role_id)
if role:
await interaction.user.add_roles(role)
await interaction.response.send_message("✅ Você foi verificado com
sucesso!", ephemeral=True)
else:
await interaction.response.send_message("❌ Erro ao atribuir o cargo.",
ephemeral=True)
class Verification(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="enviarverificacao")
@commands.has_permissions(administrator=True)
async def enviar_verificacao(self, ctx):
canal = self.bot.get_channel(config["verification_channel_id"])
if canal:
view = VerificationView(config["verified_role_id"])
await canal.send("Clique no botão abaixo para se verificar:",
view=view)
else:
await ctx.send("❌ Canal de verificação não encontrado.")
async def setup(bot):
await bot.add_cog(Verification(bot))
# cogs/tickets.py
import discord
from discord.ext import commands
from discord.ui import View, Button
class TicketView(View):
def __init__(self, bot):
super().__init__(timeout=None)
self.bot = bot
@discord.ui.button(label=" Abrir Ticket", style=discord.ButtonStyle.primary,
custom_id="abrir_ticket")
async def open_ticket(self, interaction: discord.Interaction, button:
discord.ui.Button):
guild = interaction.guild
category = guild.get_channel(config["ticket_category_id"])
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
interaction.user: discord.PermissionOverwrite(read_messages=True,
send_messages=True),
guild.get_role(config["staff_role_id"]):
discord.PermissionOverwrite(read_messages=True, send_messages=True)
}
ticket_channel = await guild.create_text_channel(name=f"🎫・ticket-
{interaction.user.name}",
category=category,
overwrites=overwrites)
await ticket_channel.send(f"{interaction.user.mention}, um membro da staff
estará com você em breve.")
await interaction.response.send_message(f"✅ Ticket criado:
{ticket_channel.mention}", ephemeral=True)
log_channel = guild.get_channel(config["log_channel_id"])
if log_channel:
await log_channel.send(f"📩 Ticket criado por
{interaction.user.mention}: {ticket_channel.mention}")
class Tickets(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="enviarticket")
@commands.has_permissions(administrator=True)
async def enviar_ticket(self, ctx):
view = TicketView(self.bot)
await ctx.send("Clique no botão abaixo para abrir um ticket de suporte:",
view=view)
async def setup(bot):
await bot.add_cog(Tickets(bot))
# (Demais módulos ainda serão implementados conforme instruções)
#cogs/reputação.py
import discord
from discord.ext import commands
import json
import os
class Reputation(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.data_file = "reputation_data.json"
if not os.path.exists(self.data_file):
with open(self.data_file, "w") as f:
json.dump({}, f)
with open(self.data_file, "r") as f:
self.reputation_data = json.load(f)
def save_data(self):
with open(self.data_file, "w") as f:
json.dump(self.reputation_data, f, indent=4)
@commands.command(name="reputar")
async def give_reputation(self, ctx, member: discord.Member):
if member.id == ctx.author.id:
await ctx.send("❌ Você não pode se dar reputação!")
return
user_id = str(member.id)
self.reputation_data[user_id] = self.reputation_data.get(user_id, 0) + 1
self.save_data()
await ctx.send(f"✅ Você deu uma reputação para {member.mention}. Total
agora: {self.reputation_data[user_id]}")
@commands.command(name="reputacao")
async def check_reputation(self, ctx, member: discord.Member = None):
member = member or ctx.author
user_id = str(member.id)
rep = self.reputation_data.get(user_id, 0)
await ctx.send(f"⭐ {member.mention} tem {rep} reputação.")
async def setup(bot):
await bot.add_cog(Reputation(bot))
# cogs/anuncios.py
import discord
from discord.ext import commands, tasks
import json
import os
class Anuncios(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.file = "data/anuncios.json"
os.makedirs("data", exist_ok=True)
if not os.path.exists(self.file):
with open(self.file, "w") as f:
json.dump([], f)
self.anunciar.start()
def carregar_anuncios(self):
with open(self.file, "r") as f:
return json.load(f)
@tasks.loop(seconds=60)
async def anunciar(self):
anuncios = self.carregar_anuncios()
if not anuncios:
return
for anuncio in anuncios:
canal = self.bot.get_channel(anuncio["channel_id"])
if canal:
await canal.send(embed=discord.Embed(
title="📢 Anúncio Automático",
description=anuncio["mensagem"],
color=0xffc107
))
@commands.command(name="addanuncio")
@commands.has_permissions(administrator=True)
async def add_anuncio(self, ctx, canal: discord.TextChannel, *, mensagem):
anuncios = self.carregar_anuncios()
anuncios.append({
"channel_id": canal.id,
"mensagem": mensagem
})
with open(self.file, "w") as f:
json.dump(anuncios, f, indent=4)
await ctx.send(f"✅ Anúncio adicionado para o canal {canal.mention}.")
@commands.command(name="limparanuncios")
@commands.has_permissions(administrator=True)
async def limpar_anuncios(self, ctx):
with open(self.file, "w") as f:
json.dump([], f)
await ctx.send("✅ Todos os anúncios automáticos foram removidos.")
@commands.command(name="listar_anuncios")
@commands.has_permissions(administrator=True)
async def listar_anuncios(self, ctx):
anuncios = self.carregar_anuncios()
if not anuncios:
return await ctx.send("ℹ️ Nenhum anúncio automático configurado.")
texto = "\n".join(
f"- Canal: <#{a['channel_id']}> | Mensagem: {a['mensagem']}" for a in
anuncios
)
await ctx.send(f"📋 **Anúncios automáticos configurados:**\n{texto}")
async def setup(bot):
await bot.add_cog(Anuncios(bot))
# cogs/autoresposta.py
import discord
from discord.ext import commands
import json
import os
class AutoResposta(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.arquivo = "data/autorespostas.json"
os.makedirs("data", exist_ok=True)
if not os.path.exists(self.arquivo):
with open(self.arquivo, "w") as f:
json.dump({}, f)
def carregar_respostas(self):
with open(self.arquivo, "r") as f:
return json.load(f)
def salvar_respostas(self, dados):
with open(self.arquivo, "w") as f:
json.dump(dados, f, indent=4)
@commands.command(name="addresposta")
@commands.has_permissions(administrator=True)
async def add_resposta(self, ctx, gatilho: str, *, resposta: str):
dados = self.carregar_respostas()
dados[gatilho.lower()] = resposta
self.salvar_respostas(dados)
await ctx.send(f"✅ Auto-resposta adicionada: `{gatilho}` → `{resposta}`")
@commands.command(name="removerresposta")
@commands.has_permissions(administrator=True)
async def remover_resposta(self, ctx, *, gatilho: str):
dados = self.carregar_respostas()
if gatilho.lower() in dados:
del dados[gatilho.lower()]
self.salvar_respostas(dados)
await ctx.send(f" Gatilho `{gatilho}` removido.")
else:
await ctx.send("❌ Gatilho não encontrado.")
@commands.command(name="listarrespostas")
async def listar_respostas(self, ctx):
dados = self.carregar_respostas()
if not dados:
return await ctx.send("📭 Nenhuma auto-resposta registrada.")
embed = discord.Embed(title="📌 Auto-Respostas Cadastradas", color=0xf1c40f)
for gatilho, resposta in dados.items():
embed.add_field(name=gatilho, value=resposta, inline=False)
await ctx.send(embed=embed)
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return
dados = self.carregar_respostas()
conteudo = message.content.lower()
for gatilho, resposta in dados.items():
if gatilho in conteudo:
await message.channel.send(resposta)
break # responde apenas ao primeiro gatilho encontrado
async def setup(bot):
await bot.add_cog(AutoResposta(bot))
#cog/moderation.py
import discord
from discord.ext import commands
from discord.utils import get
import asyncio
class Moderation(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="ban")
@commands.has_permissions(ban_members=True)
async def ban_member(self, ctx, member: discord.Member, *, reason=None):
try:
await member.ban(reason=reason)
await ctx.send(f"✅ {member} foi banido do servidor.")
except Exception as e:
await ctx.send(f"❌ Erro ao banir: {e}")
@commands.command(name="kick")
@commands.has_permissions(kick_members=True)
async def kick_member(self, ctx, member: discord.Member, *, reason=None):
try:
await member.kick(reason=reason)
await ctx.send(f"✅ {member} foi expulso do servidor.")
except Exception as e:
await ctx.send(f"❌ Erro ao expulsar: {e}")
@commands.command(name="mute")
@commands.has_permissions(manage_roles=True)
async def mute_member(self, ctx, member: discord.Member, duration: int = 10, *,
reason=None):
muted_role = get(ctx.guild.roles, name="Mutado")
if not muted_role:
muted_role = await ctx.guild.create_role(name="Mutado")
for channel in ctx.guild.channels:
await channel.set_permissions(muted_role, speak=False,
send_messages=False, read_message_history=True, read_messages=False)
await member.add_roles(muted_role, reason=reason)
await ctx.send(f"🔇 {member.mention} foi mutado por {duration} minutos.
Motivo: {reason if reason else 'Não especificado.'}")
await asyncio.sleep(duration * 60)
await member.remove_roles(muted_role)
await ctx.send(f"🔊 {member.mention} foi desmutado automaticamente após
{duration} minutos.")
@commands.command(name="limpar")
@commands.has_permissions(manage_messages=True)
async def clear_messages(self, ctx, amount: int = 10):
deleted = await ctx.channel.purge(limit=amount)
await ctx.send(f"🧹 {len(deleted)} mensagens deletadas.", delete_after=5)
async def setup(bot):
await bot.add_cog(Moderation(bot))
#cogs/terms.py
import discord
from discord.ext import commands
from discord.ui import View, Button
class TermsView(View):
def __init__(self, role_id):
super().__init__(timeout=None)
self.role_id = role_id
@discord.ui.button(label="Aceitar Termos", style=discord.ButtonStyle.success,
custom_id="accept_terms")
async def accept_terms(self, interaction: discord.Interaction, button:
discord.ui.Button):
role = interaction.guild.get_role(self.role_id)
if not role:
await interaction.response.send_message("❌ Cargo de aceitação não
configurado.", ephemeral=True)
return
if role in interaction.user.roles:
await interaction.response.send_message("✅ Você já aceitou os termos.",
ephemeral=True)
return
await interaction.user.add_roles(role)
await interaction.response.send_message("✅ Termos aceitos com sucesso! Bem-
vindo ao servidor.", ephemeral=True)
class Terms(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="enviartermos")
@commands.has_permissions(administrator=True)
async def enviar_termos(self, ctx):
role_id = config.get("terms_role_id")
if not role_id:
await ctx.send("❌ Cargo para aceitação dos termos não configurado no
config.json.")
return
view = TermsView(role_id)
await ctx.send(
"Por favor, leia e aceite os termos de uso para acessar o servidor
clicando no botão abaixo.",
view=view
)
async def setup(bot):
await bot.add_cog(Terms(bot))
#cogs/dashboard.py
import discord
from discord.ext import commands
import json
import os
class Dashboard(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.reputation_file = "reputation_data.json"
def get_total_reputation(self):
if not os.path.exists(self.reputation_file):
return 0
with open(self.reputation_file, "r") as f:
data = json.load(f)
return sum(data.values())
@commands.command(name="painel")
@commands.has_permissions(administrator=True)
async def painel(self, ctx):
guild = ctx.guild
total_members = guild.member_count
online_members = sum(m.status != discord.Status.offline for m in
guild.members)
total_reputation = self.get_total_reputation()
# Contar canais de tickets abertos - considerando que tickets ficam em
categoria específica
ticket_category_id = self.bot.config.get("ticket_category_id")
ticket_category = guild.get_channel(ticket_category_id) if
ticket_category_id else None
open_tickets = len(ticket_category.channels) if ticket_category else 0
embed = discord.Embed(title="📊 Painel de Estatísticas do Servidor",
color=discord.Color.blue())
embed.add_field(name="👥 Total de membros", value=str(total_members),
inline=True)
embed.add_field(name="🟢 Membros online", value=str(online_members),
inline=True)
embed.add_field(name="🎟 Tickets abertos", value=str(open_tickets),
inline=True)
embed.add_field(name="⭐ Reputação total", value=str(total_reputation),
inline=True)
await ctx.send(embed=embed)
async def setup(bot):
await bot.add_cog(Dashboard(bot))