Primeiro commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
python WIPBOT.py
|
python WIPBOT.py
|
||||||
=======
|
=======
|
||||||
python3 WIPBOT.py
|
python3 WIPBOT.py
|
||||||
@@ -7,3 +8,6 @@ python3 WIPBOT.py
|
|||||||
=======
|
=======
|
||||||
python WIPBOT.py
|
python WIPBOT.py
|
||||||
>>>>>>> 462e052 (Salvando alterações locais antes de rebase)
|
>>>>>>> 462e052 (Salvando alterações locais antes de rebase)
|
||||||
|
=======
|
||||||
|
web: python WIPBOT.py
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485
|
||||||
|
|||||||
@@ -1,31 +1,99 @@
|
|||||||
# 🛡️ WIP Dungeon Organizer Bot — by kl3z
|
# World of Warcraft Dungeon Group Bot (WoW LFG Bot)
|
||||||
|
|
||||||
Bot para Discord criado para a comunidade **Work-in-Progress (WIP)**, que permite aos jogadores de **World of Warcraft** organizarem-se automaticamente em grupos para dungeons, de forma prática e interativa.
|
This is a Python bot developed with discord.py, designed to automate and organize the creation of Mythic+ dungeon groups in Discord, simplifying the scheduling, sign-up, and player management process based on their roles and classes in World of Warcraft.
|
||||||
|
|
||||||
---
|
## Main Features
|
||||||
|
|
||||||
## ✨ Funcionalidades
|
### 🎯 Group creation with interactive embed displaying:
|
||||||
|
|
||||||
- 🎭 **Reações por role** – jogadores escolhem ser:
|
- *Selected dungeon*
|
||||||
- 🛡️ **Tank**
|
|
||||||
- 💚 **Healer**
|
|
||||||
- ⚔️ **DPS**
|
|
||||||
|
|
||||||
- 📊 **Limites automáticos por role**:
|
- *Keystone level (+X)*
|
||||||
- 1 Tank, 1 Healer e 3 DPS por grupo.
|
|
||||||
|
|
||||||
- 🧙 **Seleção de classes** com dropdowns personalizados, incluindo ícones das classes.
|
- *Scheduled date and time*
|
||||||
|
|
||||||
- 🏰 **Escolha da dungeon e dificuldade da mesma** (de 0 a 20+) via menus interativos.
|
- *Dynamic player list by role and class*
|
||||||
|
|
||||||
- 📅 **Definição de data e hora** através de modal intuitivo.
|
### 🧩 Role signup (Tank, Healer, DPS) with automatic limits:
|
||||||
|
|
||||||
- ♻️ **Atualização dinâmica** do embed com os inscritos e respetivas classes.
|
- *1 Tank*
|
||||||
|
|
||||||
---
|
- *1 Healer*
|
||||||
|
|
||||||
## ⚙️ Comando principal
|
- *3 DPS*
|
||||||
|
|
||||||
|
🧙 Class selection is only available after choosing a role, with specific icons and names for each specialization.
|
||||||
|
|
||||||
|
### ⛔ Player lock system:
|
||||||
|
|
||||||
|
- *Only one player can sign up at a time.*
|
||||||
|
|
||||||
|
- *The role selection process is blocked until the class is chosen.*
|
||||||
|
|
||||||
|
### 🏰 Dungeon and Difficulty selection via dropdown menus (SelectDropdown):
|
||||||
|
|
||||||
|
- *Configurable only once*
|
||||||
|
|
||||||
|
- *The thread title is updated with the selected dungeon and difficulty*
|
||||||
|
|
||||||
|
### 📆 Date and Time setup via Modal:
|
||||||
|
|
||||||
|
- *Ensures the groups are scheduled for future times*
|
||||||
|
|
||||||
|
## 📬 Forum channel post creation:
|
||||||
|
|
||||||
|
- *Allows threads to be created with custom names and deletes dropdowns after use*
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
!bot
|
||||||
|
```
|
||||||
|
|
||||||
|
## 💡 Libraries Used
|
||||||
|
|
||||||
|
- *discord.py (Discord bot API)*
|
||||||
|
|
||||||
|
- *python-dotenv (Management of tokens and environment variables)*
|
||||||
|
|
||||||
|
- *asyncio (Scheduled tasks like deleting threads)*
|
||||||
|
|
||||||
|
- *datetime (Date and time management)*
|
||||||
|
|
||||||
|
## 🚀 How to Use
|
||||||
|
|
||||||
|
- *Create a server with a forum channel named lfg*
|
||||||
|
|
||||||
|
- *Use the command /criargrupo or !criargrupo to start a new group:*
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
!criargrupo
|
!criargrupo
|
||||||
|
```
|
||||||
|
- *Players must choose their role → class → and they are signed up*
|
||||||
|
|
||||||
|
- *Dungeon, difficulty, and date are selected through intuitive menus*
|
||||||
|
|
||||||
|
## 📌 Visual Example
|
||||||
|
|
||||||
|
<img width="743" height="647" alt="image" src="https://github.com/user-attachments/assets/105c68fc-2541-4c56-84b6-a4290999a97b" />
|
||||||
|
Additionally, the bot can be added to a channel, and using the command /bot or !bot, it creates a post in the lfg forum:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
!bot
|
||||||
|
```
|
||||||
|
This option also allows the user to select the type of stack they may want:
|
||||||
|
|
||||||
|
<img width="694" height="215" alt="image" src="https://github.com/user-attachments/assets/9c171624-367f-427e-869f-b860776d5204" />
|
||||||
|
|
||||||
|
## 🔐 Security
|
||||||
|
|
||||||
|
- *The bot respects the limits for each role*
|
||||||
|
|
||||||
|
- *Prevents more than one player from selecting a role at the same time*
|
||||||
|
|
||||||
|
- *Removes interaction elements after use to avoid spam*
|
||||||
|
|
||||||
|
## 👨💻 Developed by
|
||||||
|
Kl3z – This project is open-source and can be adapted for any WoW community.
|
||||||
|
|
||||||
|
[Bot](https://discord.com/oauth2/authorize?client_id=1400140850029133834&permissions=0&integration_type=0&scope=bot)
|
||||||
|
|
||||||
|
|||||||
+318
-46
@@ -1,3 +1,4 @@
|
|||||||
|
#!pip install discord.py python-dotenv
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ui import View, Select, Button, Modal, TextInput
|
from discord.ui import View, Select, Button, Modal, TextInput
|
||||||
@@ -27,6 +28,7 @@ DUNGEONS = [
|
|||||||
]
|
]
|
||||||
DIFICULDADES = [str(i) for i in range(0, 21)] + ["20+"]
|
DIFICULDADES = [str(i) for i in range(0, 21)] + ["20+"]
|
||||||
LIMITES = {"Tank": 1, "Healer": 1, "DPS": 3}
|
LIMITES = {"Tank": 1, "Healer": 1, "DPS": 3}
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
grupo_mensagem_id = None
|
grupo_mensagem_id = None
|
||||||
inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
||||||
classes_escolhidas = {}
|
classes_escolhidas = {}
|
||||||
@@ -35,6 +37,17 @@ dificuldade_escolhida = "10"
|
|||||||
data_formatada = "06/08/2025"
|
data_formatada = "06/08/2025"
|
||||||
hora_escolhida = "22:00"
|
hora_escolhida = "22:00"
|
||||||
alteracoes_feitas = {"dungeon": False, "dificuldade": False, "data": False}
|
alteracoes_feitas = {"dungeon": False, "dificuldade": False, "data": False}
|
||||||
|
=======
|
||||||
|
# grupo_mensagem_id = None
|
||||||
|
# inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
||||||
|
# classes_escolhidas = {}
|
||||||
|
# dungeon_escolhida = DUNGEONS[2]
|
||||||
|
# dificuldade_escolhida = "10"
|
||||||
|
# data_formatada = "06/08/2025"
|
||||||
|
# hora_escolhida = "22:00"
|
||||||
|
# alteracoes_feitas = {"dungeon": False, "dificuldade": False, "data": False}
|
||||||
|
# jogador_em_progresso = None
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
def format_grupo_embed():
|
def format_grupo_embed():
|
||||||
def format_role(role):
|
def format_role(role):
|
||||||
@@ -74,7 +87,12 @@ async def criar_grupo_customizado(canal):
|
|||||||
view=RoleView("Novo jogador", canal.id, grupo_mensagem_id)
|
view=RoleView("Novo jogador", canal.id, grupo_mensagem_id)
|
||||||
)
|
)
|
||||||
class StackDropdown(Select):
|
class StackDropdown(Select):
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
=======
|
||||||
|
def __init__(self, grupo):
|
||||||
|
self.grupo = grupo
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
options = [
|
options = [
|
||||||
discord.SelectOption(label="Plate Stack"),
|
discord.SelectOption(label="Plate Stack"),
|
||||||
discord.SelectOption(label="Leather Stack"),
|
discord.SelectOption(label="Leather Stack"),
|
||||||
@@ -82,6 +100,10 @@ class StackDropdown(Select):
|
|||||||
discord.SelectOption(label="Cloth Stack")
|
discord.SelectOption(label="Cloth Stack")
|
||||||
]
|
]
|
||||||
super().__init__(placeholder="Escolhe o tipo de stack", options=options)
|
super().__init__(placeholder="Escolhe o tipo de stack", options=options)
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
escolha = self.values[0]
|
escolha = self.values[0]
|
||||||
forum_channel = discord.utils.get(interaction.guild.channels, name="lfg", type=discord.ChannelType.forum)
|
forum_channel = discord.utils.get(interaction.guild.channels, name="lfg", type=discord.ChannelType.forum)
|
||||||
@@ -91,10 +113,20 @@ class StackDropdown(Select):
|
|||||||
thread = await forum_channel.create_thread(name=escolha, content=escolha)
|
thread = await forum_channel.create_thread(name=escolha, content=escolha)
|
||||||
await interaction.message.delete()
|
await interaction.message.delete()
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
|
=======
|
||||||
|
|
||||||
|
class StackView(View):
|
||||||
|
def __init__(self, grupo):
|
||||||
|
super().__init__()
|
||||||
|
self.grupo = grupo
|
||||||
|
self.add_item(StackDropdown(grupo))
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
|
|
||||||
@bot.command(name="bot")
|
@bot.command(name="bot")
|
||||||
async def bot_command(ctx):
|
async def bot_command(ctx):
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
await ctx.send(view=StackView())
|
await ctx.send(view=StackView())
|
||||||
membro = discord.utils.get(ctx.guild.members, name="carlitosqt")
|
membro = discord.utils.get(ctx.guild.members, name="carlitosqt")
|
||||||
if membro:
|
if membro:
|
||||||
@@ -115,75 +147,135 @@ CLASSES_POR_ROLE = {
|
|||||||
("Vengeance Demon Hunter","https://wow.zamimg.com/images/wow/icons/large/ability_demonhunter_specdps.jpg"),
|
("Vengeance Demon Hunter","https://wow.zamimg.com/images/wow/icons/large/ability_demonhunter_specdps.jpg"),
|
||||||
("Brewmaster Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_brewmaster_spec.jpg"),
|
("Brewmaster Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_brewmaster_spec.jpg"),
|
||||||
("Guardian Druid", "https://wow.zamimg.com/images/wow/icons/large/ability_racial_bearform.jpg")
|
("Guardian Druid", "https://wow.zamimg.com/images/wow/icons/large/ability_racial_bearform.jpg")
|
||||||
|
=======
|
||||||
|
grupo_temporario = GrupoDungeon()
|
||||||
|
await ctx.send(view=StackView(grupo_temporario))
|
||||||
|
|
||||||
|
membro = discord.utils.get(ctx.guild.members, name="carlitosqt")
|
||||||
|
if membro:
|
||||||
|
await ctx.send(f"Parabéns {membro.mention}!")
|
||||||
|
|
||||||
|
CLASSES_POR_ROLE = {
|
||||||
|
"Tank": [
|
||||||
|
("Paladin", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_avengershield.jpg"),
|
||||||
|
("Warrior", "https://wow.zamimg.com/images/wow/icons/large/spell_warrior_protetion_spec.jpg"),
|
||||||
|
("Death Knight", "https://wow.zamimg.com/images/wow/icons/large/spell_deathknight_bloodpresence.jpg"),
|
||||||
|
("Demon Hunter","https://wow.zamimg.com/images/wow/icons/large/ability_demonhunter_specdps.jpg"),
|
||||||
|
("Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_brewmaster_spec.jpg"),
|
||||||
|
("Druid", "https://wow.zamimg.com/images/wow/icons/large/ability_racial_bearform.jpg")
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
],
|
],
|
||||||
"Healer": [
|
"Healer": [
|
||||||
("Discipline Priest", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_powerwordshield.jpg"),
|
("Priest", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_powerwordshield.jpg"),
|
||||||
("Restoration Shaman", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_magicimmunity.jpg"),
|
("Shaman", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_magicimmunity.jpg"),
|
||||||
("Mistweaver Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_mistweaver_spec.jpg"),
|
("Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_mistweaver_spec.jpg"),
|
||||||
("Restoration Druid", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_healingtouch.jpg"),
|
("Druid", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_healingtouch.jpg"),
|
||||||
("Holy Paladin", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_holybolt.jpg"),
|
("Paladin", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_holybolt.jpg"),
|
||||||
("Preservation Evoker", "https://wow.zamimg.com/images/wow/icons/large/spell_spec_evoker_preservation.jpg")
|
("Evoker", "https://wow.zamimg.com/images/wow/icons/large/spell_spec_evoker_preservation.jpg")
|
||||||
],
|
],
|
||||||
"DPS": [
|
"DPS": [
|
||||||
("Arcane Mage", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_magicalsentry.jpg"),
|
("Mage", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_magicalsentry.jpg"),
|
||||||
("Balance Druid", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_starfall.jpg"),
|
("Druid", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_starfall.jpg"),
|
||||||
("Unholy Death Knight", "https://wow.zamimg.com/images/wow/icons/large/spell_deathknight_unholypresence.png"),
|
("Paladin", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_auraoflight.jpg"),
|
||||||
("Retribution Paladin", "https://wow.zamimg.com/images/wow/icons/large/spell_holy_auraoflight.jpg"),
|
("Shaman", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_lightning.jpg"),
|
||||||
("Fire Mage", "https://wow.zamimg.com/images/wow/icons/large/spell_fire_flamebolt.jpg"),
|
("Hunter", "https://wow.zamimg.com/images/wow/icons/large/ability_hunter_bestialdiscipline.jpg"),
|
||||||
("Elemental Shaman", "https://wow.zamimg.com/images/wow/icons/large/spell_nature_lightning.jpg"),
|
("Rogue", "https://wow.zamimg.com/images/wow/icons/large/ability_rogue_deadlybrew.jpg"),
|
||||||
("Enhancement Shaman", "https://wow.zamimg.com/images/wow/icons/large/spell_shaman_improvedstormstrike.jpg"),
|
("Demon Hunter","https://wow.zamimg.com/images/wow/icons/large/ability_demonhunter_specdps.jpg"),
|
||||||
("Marksmanship Hunter", "https://wow.zamimg.com/images/wow/icons/large/ability_hunter_focusedaim.jpg"),
|
("Priest", "https://wow.zamimg.com/images/wow/icons/large/spell_shadow_shadowwordpain.jpg"),
|
||||||
("Havoc Demon Hunter", "https://wow.zamimg.com/images/wow/icons/large/ability_demonhunter_specdps.jpg"),
|
("Death Knight", "https://wow.zamimg.com/images/wow/icons/large/spell_deathknight_frostpresence.png"),
|
||||||
("Beast Mastery Hunter", "https://wow.zamimg.com/images/wow/icons/large/ability_hunter_bestialdiscipline.jpg"),
|
("Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_windwalkerspec.jpg"),
|
||||||
("Assassination Rogue", "https://wow.zamimg.com/images/wow/icons/large/ability_rogue_deadlybrew.jpg"),
|
("Warrior", "https://wow.zamimg.com/images/wow/icons/large/ability_warrior_innerrage.jpg"),
|
||||||
("Outlaw Rogue", "https://wow.zamimg.com/images/wow/icons/large/ability_rogue_waylay.jpg"),
|
("Warlock", "https://wow.zamimg.com/images/wow/icons/large/spell_shadow_deathcoil.jpg"),
|
||||||
("Shadow Priest", "https://wow.zamimg.com/images/wow/icons/large/spell_shadow_shadowwordpain.jpg"),
|
("Evoker", "https://wow.zamimg.com/images/wow/icons/large/spell_spec_evoker_devastation.jpg")
|
||||||
("Frost Death Knight", "https://wow.zamimg.com/images/wow/icons/large/spell_deathknight_frostpresence.png"),
|
|
||||||
("Windwalker Monk", "https://wow.zamimg.com/images/wow/icons/large/spell_monk_windwalkerspec.jpg"),
|
|
||||||
("Fury Warrior", "https://wow.zamimg.com/images/wow/icons/large/ability_warrior_innerrage.jpg"),
|
|
||||||
("Arms Warrior", "https://wow.zamimg.com/images/wow/icons/large/ability_warrior_savageblow.jpg"),
|
|
||||||
("Affliction Warlock", "https://wow.zamimg.com/images/wow/icons/large/spell_shadow_deathcoil.jpg"),
|
|
||||||
("Destruction Warlock", "https://wow.zamimg.com/images/wow/icons/large/spell_shadow_rainoffire.jpg"),
|
|
||||||
("Feral Druid", "https://wow.zamimg.com/images/wow/icons/large/ability_druid_catform.jpg"),
|
|
||||||
("Devastation Evoker", "https://wow.zamimg.com/images/wow/icons/large/spell_spec_evoker_devastation.jpg"),
|
|
||||||
("Survival Hunter", "https://wow.zamimg.com/images/wow/icons/large/ability_hunter_camouflage.jpg"),
|
|
||||||
("Frost Mage", "https://wow.zamimg.com/images/wow/icons/large/spell_frost_frostbolt02.jpg")
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
class DungeonDropdown(Select):
|
class DungeonDropdown(Select):
|
||||||
|
=======
|
||||||
|
|
||||||
|
class GrupoDungeon:
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
||||||
|
self.classes_escolhidas = {}
|
||||||
|
self.dungeon_escolhida = DUNGEONS[2]
|
||||||
|
self.dificuldade_escolhida = "10"
|
||||||
|
self.data_formatada = "06/08/2025"
|
||||||
|
self.hora_escolhida = "22:00"
|
||||||
|
self.alteracoes_feitas = {"dungeon": False, "dificuldade": False, "data": False}
|
||||||
|
self.jogador_em_progresso = None
|
||||||
|
self.mensagem_id = None
|
||||||
|
self.canal_id = None
|
||||||
|
self.thread = None
|
||||||
|
|
||||||
|
def format_grupo_embed(self):
|
||||||
|
def format_role(role):
|
||||||
|
players = self.inscritos[role]
|
||||||
|
if not players:
|
||||||
|
return "None"
|
||||||
|
return "\n".join(f"{p} ({self.classes_escolhidas.get(p, 'sem classe')})" for p in players)
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title=f"Dungeon: {self.dungeon_escolhida}",
|
||||||
|
description=(
|
||||||
|
f"Dificuldade: {self.dificuldade_escolhida}\n"
|
||||||
|
f"Marcação: {self.data_formatada} às {self.hora_escolhida}"
|
||||||
|
),
|
||||||
|
color=0x00ffcc
|
||||||
|
)
|
||||||
|
embed.add_field(name=f"{EMOJI_TANK} Tank", value=format_role("Tank"), inline=False)
|
||||||
|
embed.add_field(name=f"{EMOJI_HEALER} Healer", value=format_role("Healer"), inline=False)
|
||||||
|
embed.add_field(name=f"{EMOJI_DPS} DPS", value=format_role("DPS"), inline=False)
|
||||||
|
embed.set_footer(text="Bot created by Kl3z")
|
||||||
|
return embed
|
||||||
|
|
||||||
|
grupos_ativos = {}
|
||||||
|
|
||||||
|
class DungeonDropdown(Select):
|
||||||
|
def __init__(self, grupo: GrupoDungeon):
|
||||||
|
self.grupo = grupo
|
||||||
options = [discord.SelectOption(label=d, value=d) for d in DUNGEONS]
|
options = [discord.SelectOption(label=d, value=d) for d in DUNGEONS]
|
||||||
super().__init__(placeholder="Escolhe a dungeon", min_values=1, max_values=1, options=options)
|
super().__init__(placeholder="Escolhe a dungeon", min_values=1, max_values=1, options=options)
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
global dungeon_escolhida
|
if self.grupo.alteracoes_feitas["dungeon"]:
|
||||||
if alteracoes_feitas["dungeon"]:
|
|
||||||
await interaction.response.send_message("❌ A dungeon já foi escolhida e não pode ser alterada novamente.", ephemeral=True)
|
await interaction.response.send_message("❌ A dungeon já foi escolhida e não pode ser alterada novamente.", ephemeral=True)
|
||||||
return
|
return
|
||||||
dungeon_escolhida = self.values[0]
|
|
||||||
alteracoes_feitas["dungeon"] = True
|
self.grupo.dungeon_escolhida = self.values[0]
|
||||||
|
self.grupo.alteracoes_feitas["dungeon"] = True
|
||||||
|
|
||||||
mensagem = await interaction.channel.fetch_message(grupo_mensagem_id)
|
canal = bot.get_channel(self.grupo.canal_id)
|
||||||
nova_view = DungeonView()
|
mensagem = await canal.fetch_message(self.grupo.mensagem_id)
|
||||||
if all(alteracoes_feitas.values()):
|
|
||||||
|
nova_view = DungeonView(self.grupo)
|
||||||
|
if all(self.grupo.alteracoes_feitas.values()):
|
||||||
nova_view.clear_items()
|
nova_view.clear_items()
|
||||||
|
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
||||||
if isinstance(interaction.channel, discord.Thread):
|
if isinstance(interaction.channel, discord.Thread):
|
||||||
await interaction.channel.edit(name=f"{dungeon_escolhida} - Key {dificuldade_escolhida}")
|
await interaction.channel.edit(name=f"{dungeon_escolhida} - Key {dificuldade_escolhida}")
|
||||||
|
=======
|
||||||
|
await mensagem.edit(embed=self.grupo.format_grupo_embed(), view=nova_view)
|
||||||
|
|
||||||
|
if self.grupo.thread:
|
||||||
|
await self.grupo.thread.edit(name=f"{self.grupo.dungeon_escolhida} - Key {self.grupo.dificuldade_escolhida}")
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
class DificuldadeDropdown(Select):
|
class DificuldadeDropdown(Select):
|
||||||
def __init__(self):
|
def __init__(self, grupo):
|
||||||
|
self.grupo = grupo
|
||||||
options = [discord.SelectOption(label=f"Chave {d}", value=d) for d in DIFICULDADES]
|
options = [discord.SelectOption(label=f"Chave {d}", value=d) for d in DIFICULDADES]
|
||||||
super().__init__(placeholder="Escolhe a dificuldade", min_values=1, max_values=1, options=options)
|
super().__init__(placeholder="Escolhe a dificuldade", min_values=1, max_values=1, options=options)
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
global dificuldade_escolhida
|
if self.grupo.alteracoes_feitas["dificuldade"]:
|
||||||
if alteracoes_feitas["dificuldade"]:
|
|
||||||
await interaction.response.send_message("❌ A dificuldade já foi definida e não pode ser alterada novamente.", ephemeral=True)
|
await interaction.response.send_message("❌ A dificuldade já foi definida e não pode ser alterada novamente.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
dificuldade_escolhida = self.values[0]
|
dificuldade_escolhida = self.values[0]
|
||||||
alteracoes_feitas["dificuldade"] = True
|
alteracoes_feitas["dificuldade"] = True
|
||||||
mensagem = await interaction.channel.fetch_message(grupo_mensagem_id)
|
mensagem = await interaction.channel.fetch_message(grupo_mensagem_id)
|
||||||
@@ -193,16 +285,36 @@ class DificuldadeDropdown(Select):
|
|||||||
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
||||||
if isinstance(interaction.channel, discord.Thread):
|
if isinstance(interaction.channel, discord.Thread):
|
||||||
await interaction.channel.edit(name=f"{dungeon_escolhida} - Key {dificuldade_escolhida}")
|
await interaction.channel.edit(name=f"{dungeon_escolhida} - Key {dificuldade_escolhida}")
|
||||||
|
=======
|
||||||
|
|
||||||
|
self.grupo.dificuldade_escolhida = self.values[0]
|
||||||
|
self.grupo.alteracoes_feitas["dificuldade"] = True
|
||||||
|
|
||||||
|
canal = bot.get_channel(self.grupo.canal_id)
|
||||||
|
mensagem = await canal.fetch_message(self.grupo.mensagem_id)
|
||||||
|
nova_view = DungeonView(self.grupo)
|
||||||
|
if all(self.grupo.alteracoes_feitas.values()):
|
||||||
|
nova_view.clear_items()
|
||||||
|
|
||||||
|
await mensagem.edit(embed=self.grupo.format_grupo_embed(), view=nova_view)
|
||||||
|
|
||||||
|
if self.grupo.thread:
|
||||||
|
await self.grupo.thread.edit(name=f"{self.grupo.dungeon_escolhida} - Key {self.grupo.dificuldade_escolhida}")
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
class DataModal(Modal, title="Definir Data da Dungeon"):
|
class DataModal(Modal, title="Definir Data da Dungeon"):
|
||||||
dia = TextInput(label="Dia do mês (1-31)", placeholder="Ex: 6", max_length=2)
|
def __init__(self, grupo):
|
||||||
hora = TextInput(label="Hora (HH:MM)", placeholder="Ex: 22:30", max_length=5)
|
super().__init__()
|
||||||
|
self.grupo = grupo
|
||||||
|
self.dia = TextInput(label="Dia do mês (1-31)", placeholder="Ex: 6", max_length=2)
|
||||||
|
self.hora = TextInput(label="Hora (HH:MM)", placeholder="Ex: 22:30", max_length=5)
|
||||||
|
self.add_item(self.dia)
|
||||||
|
self.add_item(self.hora)
|
||||||
|
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
global data_formatada, hora_escolhida
|
if self.grupo.alteracoes_feitas["data"]:
|
||||||
if alteracoes_feitas["data"]:
|
|
||||||
await interaction.response.send_message("❌ A data e hora já foram definidas e não podem ser alteradas novamente.", ephemeral=True)
|
await interaction.response.send_message("❌ A data e hora já foram definidas e não podem ser alteradas novamente.", ephemeral=True)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
@@ -221,8 +333,21 @@ class DataModal(Modal, title="Definir Data da Dungeon"):
|
|||||||
ano += 1
|
ano += 1
|
||||||
data_completa = datetime(year=ano, month=mes, day=dia_num)
|
data_completa = datetime(year=ano, month=mes, day=dia_num)
|
||||||
|
|
||||||
|
self.grupo.data_formatada = data_completa.strftime("%d/%m/%Y")
|
||||||
|
self.grupo.hora_escolhida = hora_val
|
||||||
|
self.grupo.alteracoes_feitas["data"] = True
|
||||||
|
|
||||||
|
canal = bot.get_channel(self.grupo.canal_id)
|
||||||
|
mensagem = await canal.fetch_message(self.grupo.mensagem_id)
|
||||||
|
nova_view = DungeonView(self.grupo)
|
||||||
|
if all(self.grupo.alteracoes_feitas.values()):
|
||||||
|
nova_view.clear_items()
|
||||||
|
await mensagem.edit(embed=self.grupo.format_grupo_embed(), view=nova_view)
|
||||||
|
await interaction.response.defer()
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
await interaction.response.send_message("❌ Data ou hora inválida.", ephemeral=True)
|
await interaction.response.send_message("❌ Data ou hora inválida.", ephemeral=True)
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
return
|
return
|
||||||
|
|
||||||
data_formatada = data_completa.strftime("%d/%m/%Y")
|
data_formatada = data_completa.strftime("%d/%m/%Y")
|
||||||
@@ -235,17 +360,21 @@ class DataModal(Modal, title="Definir Data da Dungeon"):
|
|||||||
nova_view.clear_items()
|
nova_view.clear_items()
|
||||||
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
await mensagem.edit(embed=format_grupo_embed(), view=nova_view)
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
=======
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
class BotaoData(Button):
|
class BotaoData(Button):
|
||||||
def __init__(self):
|
def __init__(self, grupo):
|
||||||
super().__init__(label="🗓️ Definir Data", style=discord.ButtonStyle.primary)
|
super().__init__(label="🗓️ Definir Data", style=discord.ButtonStyle.primary)
|
||||||
|
self.grupo = grupo
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
await interaction.response.send_modal(DataModal())
|
await interaction.response.send_modal(DataModal(self.grupo))
|
||||||
|
|
||||||
class DungeonView(View):
|
class DungeonView(View):
|
||||||
def __init__(self):
|
def __init__(self, grupo):
|
||||||
super().__init__(timeout=None)
|
super().__init__(timeout=None)
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
if not alteracoes_feitas["dungeon"]:
|
if not alteracoes_feitas["dungeon"]:
|
||||||
self.add_item(DungeonDropdown())
|
self.add_item(DungeonDropdown())
|
||||||
if not alteracoes_feitas["dificuldade"]:
|
if not alteracoes_feitas["dificuldade"]:
|
||||||
@@ -260,12 +389,32 @@ class RoleDropdown(Select):
|
|||||||
options = []
|
options = []
|
||||||
for role in LIMITES:
|
for role in LIMITES:
|
||||||
if len(inscritos[role]) < LIMITES[role]:
|
if len(inscritos[role]) < LIMITES[role]:
|
||||||
|
=======
|
||||||
|
self.grupo = grupo
|
||||||
|
if not self.grupo.alteracoes_feitas["dungeon"]:
|
||||||
|
self.add_item(DungeonDropdown(self.grupo))
|
||||||
|
if not self.grupo.alteracoes_feitas["dificuldade"]:
|
||||||
|
self.add_item(DificuldadeDropdown(self.grupo))
|
||||||
|
if not self.grupo.alteracoes_feitas["data"]:
|
||||||
|
self.add_item(BotaoData(self.grupo))
|
||||||
|
|
||||||
|
class RoleDropdown(Select):
|
||||||
|
def __init__(self, jogador, ctx_channel_id, role_msg_id, grupo):
|
||||||
|
self.jogador = jogador
|
||||||
|
self.ctx_channel_id = ctx_channel_id
|
||||||
|
self.role_msg_id = role_msg_id
|
||||||
|
self.grupo = grupo
|
||||||
|
options = []
|
||||||
|
for role in LIMITES:
|
||||||
|
if len(self.grupo.inscritos[role]) < LIMITES[role]:
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
options.append(discord.SelectOption(label=role, description="Escolher esta role"))
|
options.append(discord.SelectOption(label=role, description="Escolher esta role"))
|
||||||
|
|
||||||
placeholder = "Escolhe a tua role" if options else "Todas as roles preenchidas"
|
placeholder = "Escolhe a tua role" if options else "Todas as roles preenchidas"
|
||||||
super().__init__(placeholder=placeholder, options=options, disabled=(len(options) == 0))
|
super().__init__(placeholder=placeholder, options=options, disabled=(len(options) == 0))
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
global jogador_em_progresso
|
global jogador_em_progresso
|
||||||
jogador = interaction.user.display_name
|
jogador = interaction.user.display_name
|
||||||
if jogador_em_progresso and jogador_em_progresso != jogador:
|
if jogador_em_progresso and jogador_em_progresso != jogador:
|
||||||
@@ -322,6 +471,74 @@ class ClasseView(View):
|
|||||||
dropdown = ClasseDropdown(role, jogador)
|
dropdown = ClasseDropdown(role, jogador)
|
||||||
dropdown.ctx_channel_id = ctx_channel_id
|
dropdown.ctx_channel_id = ctx_channel_id
|
||||||
self.add_item(dropdown)
|
self.add_item(dropdown)
|
||||||
|
=======
|
||||||
|
if self.grupo.jogador_em_progresso and self.grupo.jogador_em_progresso != interaction.user.display_name:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
f"⏳ Aguarda que {self.grupo.jogador_em_progresso} termine a escolha da classe.",
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.grupo.jogador_em_progresso = interaction.user.display_name
|
||||||
|
role = self.values[0]
|
||||||
|
for r in self.grupo.inscritos:
|
||||||
|
if interaction.user.display_name in self.grupo.inscritos[r]:
|
||||||
|
self.grupo.inscritos[r].remove(interaction.user.display_name)
|
||||||
|
|
||||||
|
if interaction.user.display_name not in self.grupo.inscritos[role] and len(self.grupo.inscritos[role]) < LIMITES[role]:
|
||||||
|
self.grupo.inscritos[role].append(interaction.user.display_name)
|
||||||
|
canal = bot.get_channel(self.ctx_channel_id)
|
||||||
|
|
||||||
|
if isinstance(canal, discord.Thread):
|
||||||
|
await canal.join()
|
||||||
|
|
||||||
|
await interaction.message.delete()
|
||||||
|
|
||||||
|
mensagem = await canal.fetch_message(self.grupo.mensagem_id)
|
||||||
|
await mensagem.edit(embed=self.grupo.format_grupo_embed())
|
||||||
|
|
||||||
|
await canal.send(
|
||||||
|
f"{interaction.user.display_name}, agora escolhe a tua classe para **{role}**:",
|
||||||
|
view=ClasseView(role, interaction.user.display_name, self.ctx_channel_id, self.grupo)
|
||||||
|
)
|
||||||
|
|
||||||
|
await interaction.response.defer()
|
||||||
|
else:
|
||||||
|
self.grupo.jogador_em_progresso = None
|
||||||
|
await interaction.response.send_message("❌ Esta role já está cheia ou ocorreu um erro.", ephemeral=True)
|
||||||
|
|
||||||
|
class ClasseDropdown(Select):
|
||||||
|
def __init__(self, role, jogador, grupo):
|
||||||
|
self.jogador = jogador
|
||||||
|
self.role = role
|
||||||
|
self.grupo = grupo
|
||||||
|
options = [discord.SelectOption(label=nome, value=nome) for nome, _ in CLASSES_POR_ROLE[role]]
|
||||||
|
super().__init__(placeholder=f"Escolhe a classe ({role})", options=options)
|
||||||
|
|
||||||
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
self.grupo.classes_escolhidas[self.jogador] = self.values[0]
|
||||||
|
canal = interaction.channel
|
||||||
|
|
||||||
|
mensagem = await canal.fetch_message(self.grupo.mensagem_id)
|
||||||
|
await mensagem.edit(embed=self.grupo.format_grupo_embed())
|
||||||
|
|
||||||
|
await interaction.message.delete()
|
||||||
|
self.grupo.jogador_em_progresso = None
|
||||||
|
|
||||||
|
if any(len(self.grupo.inscritos[r]) < LIMITES[r] for r in LIMITES):
|
||||||
|
await canal.send(
|
||||||
|
"Escolher a tua **Role**:",
|
||||||
|
view=RoleView(interaction.user.display_name, canal.id, self.grupo.mensagem_id, self.grupo)
|
||||||
|
)
|
||||||
|
|
||||||
|
await interaction.response.defer()
|
||||||
|
|
||||||
|
class ClasseView(View):
|
||||||
|
def __init__(self, role, jogador, ctx_channel_id, grupo):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
self.grupo = grupo
|
||||||
|
self.add_item(ClasseDropdown(role, jogador, grupo))
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@@ -342,6 +559,7 @@ async def agendar_remocao_thread(thread: discord.Thread, data_str: str, hora_str
|
|||||||
|
|
||||||
@bot.command(name="criargrupo")
|
@bot.command(name="criargrupo")
|
||||||
async def criar_grupo(ctx):
|
async def criar_grupo(ctx):
|
||||||
|
<<<<<<< HEAD:backup/WIPBOT.py
|
||||||
global grupo_mensagem_id, inscritos, dungeon_escolhida, dificuldade_escolhida, data_formatada, hora_escolhida, alteracoes_feitas
|
global grupo_mensagem_id, inscritos, dungeon_escolhida, dificuldade_escolhida, data_formatada, hora_escolhida, alteracoes_feitas
|
||||||
inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
inscritos = {"Tank": [], "Healer": [], "DPS": []}
|
||||||
classes_escolhidas.clear()
|
classes_escolhidas.clear()
|
||||||
@@ -368,6 +586,60 @@ class RoleView(View):
|
|||||||
def __init__(self, jogador, ctx_channel_id, role_msg_id):
|
def __init__(self, jogador, ctx_channel_id, role_msg_id):
|
||||||
super().__init__(timeout=None)
|
super().__init__(timeout=None)
|
||||||
self.add_item(RoleDropdown(jogador, ctx_channel_id, role_msg_id))
|
self.add_item(RoleDropdown(jogador, ctx_channel_id, role_msg_id))
|
||||||
|
=======
|
||||||
|
if not (isinstance(ctx.channel, discord.ForumChannel) or
|
||||||
|
(isinstance(ctx.channel, discord.Thread) and
|
||||||
|
isinstance(ctx.channel.parent, discord.ForumChannel))):
|
||||||
|
await ctx.send("❌ Este comando só pode ser usado em um canal de fórum ou em posts de fórum!", ephemeral=True)
|
||||||
|
return
|
||||||
|
forum_channel = ctx.channel if isinstance(ctx.channel, discord.ForumChannel) else ctx.channel.parent
|
||||||
|
novo_grupo = GrupoDungeon()
|
||||||
|
|
||||||
|
try:
|
||||||
|
tags = []
|
||||||
|
dungeon_tag = discord.utils.get(forum_channel.available_tags, name=novo_grupo.dungeon_escolhida)
|
||||||
|
if dungeon_tag:
|
||||||
|
tags.append(dungeon_tag)
|
||||||
|
thread, message = await forum_channel.create_thread(
|
||||||
|
name=f"{novo_grupo.dungeon_escolhida} - Key {novo_grupo.dificuldade_escolhida}",
|
||||||
|
content=f"Dungeon group created by {ctx.author.mention}",
|
||||||
|
embed=novo_grupo.format_grupo_embed(),
|
||||||
|
view=DungeonView(novo_grupo),
|
||||||
|
applied_tags=tags
|
||||||
|
)
|
||||||
|
novo_grupo.thread = thread
|
||||||
|
novo_grupo.canal_id = thread.id
|
||||||
|
novo_grupo.mensagem_id = message.id
|
||||||
|
grupos_ativos[message.id] = novo_grupo
|
||||||
|
await thread.send(
|
||||||
|
f"{ctx.author.mention}, escolhe a tua **Role**:",
|
||||||
|
view=RoleView(ctx.author.display_name, thread.id, message.id, novo_grupo)
|
||||||
|
)
|
||||||
|
asyncio.create_task(
|
||||||
|
agendar_remocao_thread(
|
||||||
|
thread,
|
||||||
|
novo_grupo.data_formatada,
|
||||||
|
novo_grupo.hora_escolhida
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if ctx.channel.id != thread.id:
|
||||||
|
await ctx.send(f"✅ Grupo criado com sucesso! {thread.mention}", ephemeral=True)
|
||||||
|
|
||||||
|
except discord.HTTPException as e:
|
||||||
|
await ctx.send("❌ Erro ao criar post no fórum. Verifique as permissões do bot.", ephemeral=True)
|
||||||
|
print(f"Erro HTTP ao criar post: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
await ctx.send("❌ Ocorreu um erro inesperado ao criar o grupo.", ephemeral=True)
|
||||||
|
print(f"Erro ao criar grupo: {e}")
|
||||||
|
if 'thread' in locals() and thread:
|
||||||
|
await thread.delete()
|
||||||
|
|
||||||
|
class RoleView(View):
|
||||||
|
def __init__(self, jogador, ctx_channel_id, role_msg_id, grupo):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
self.grupo = grupo
|
||||||
|
self.add_item(RoleDropdown(jogador, ctx_channel_id, role_msg_id, grupo))
|
||||||
|
>>>>>>> d74e7ede443dd80ee62c43fde4fce12225656485:WIPBOT.py
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
|||||||
Reference in New Issue
Block a user