fix war channels logic
This commit is contained in:
1 parent
8ae199ab45
commit
295a90e399
2 files changed
+16
-9
No files matched your search
+2
-2
@@ -345,8 +345,8 @@ class WarMonitor(commands.Cog):
|
|||||||
await self.calc_inrange(war.att_id, channel)
|
await self.calc_inrange(war.att_id, channel)
|
||||||
|
|
||||||
# adding member to the channel
|
# adding member to the channel
|
||||||
guild = await self.bot.fetch_guild(GUILD)
|
guild = self.bot.get_guild(GUILD)
|
||||||
member = discord.utils.get(guild.members, name=defender.discord)
|
member = guild.get_member_named(defender.discord)
|
||||||
if member:
|
if member:
|
||||||
await channel.set_permissions(
|
await channel.set_permissions(
|
||||||
member, read_messages=True, send_messages=True, view_channel=True
|
member, read_messages=True, send_messages=True, view_channel=True
|
||||||
|
|||||||
+14
-7
@@ -9,8 +9,9 @@ import discord
|
|||||||
import pnwkit
|
import pnwkit
|
||||||
from utils.base import BasicView
|
from utils.base import BasicView
|
||||||
|
|
||||||
|
|
||||||
async def get_webhook(
|
async def get_webhook(
|
||||||
channel: Union[discord.TextChannel, discord.ForumChannel, discord.VoiceChannel]
|
channel: Union[discord.TextChannel, discord.ForumChannel, discord.VoiceChannel],
|
||||||
) -> discord.Webhook:
|
) -> discord.Webhook:
|
||||||
"""Get a webhook created by bot in the channel"""
|
"""Get a webhook created by bot in the channel"""
|
||||||
wname = "brahmos"
|
wname = "brahmos"
|
||||||
@@ -26,12 +27,14 @@ async def get_webhook(
|
|||||||
def discord_bg_embed(desc: str = "\u200b") -> discord.Embed:
|
def discord_bg_embed(desc: str = "\u200b") -> discord.Embed:
|
||||||
return discord.Embed(color=0x36393E, description=desc)
|
return discord.Embed(color=0x36393E, description=desc)
|
||||||
|
|
||||||
|
|
||||||
def format_count(num):
|
def format_count(num):
|
||||||
if num >= 1000:
|
if num >= 1000:
|
||||||
return f"{num/1000:,.1f}K"
|
return f"{num / 1000:,.1f}K"
|
||||||
else:
|
else:
|
||||||
return num
|
return num
|
||||||
|
|
||||||
|
|
||||||
def timeline_button(id: int):
|
def timeline_button(id: int):
|
||||||
class UrlButton(discord.ui.Button):
|
class UrlButton(discord.ui.Button):
|
||||||
def __init__(self, id: int):
|
def __init__(self, id: int):
|
||||||
@@ -45,12 +48,14 @@ def timeline_button(id: int):
|
|||||||
view.add_item(UrlButton(id))
|
view.add_item(UrlButton(id))
|
||||||
return view
|
return view
|
||||||
|
|
||||||
async def get_nation(kit: pnwkit.QueryKit, id: Union[List[int], int]) -> Union[pnwkit.Nation, List[pnwkit.Nation]]:
|
|
||||||
|
|
||||||
|
async def get_nation(
|
||||||
|
kit: pnwkit.QueryKit, id: Union[List[int], int]
|
||||||
|
) -> Union[pnwkit.Nation, List[pnwkit.Nation]]:
|
||||||
nation = await kit.query(
|
nation = await kit.query(
|
||||||
"nations",
|
"nations",
|
||||||
{"id": id},
|
{"id": id},
|
||||||
"nation_name, flag, num_cities, soldiers, tanks, aircraft, ships, missiles, score, nukes, id, alliance {name, id, flag}, discord, vacation_mode_turns, color, alliance_position",
|
"nation_name, flag, num_cities, soldiers, tanks, aircraft, ships, missiles, score, nukes, id, alliance {name, id, flag}, discord, vacation_mode_turns, color, alliance_position, leader_name",
|
||||||
)
|
)
|
||||||
if isinstance(id, list):
|
if isinstance(id, list):
|
||||||
result = []
|
result = []
|
||||||
@@ -60,11 +65,14 @@ async def get_nation(kit: pnwkit.QueryKit, id: Union[List[int], int]) -> Union[p
|
|||||||
return result
|
return result
|
||||||
return nation.nations[0]
|
return nation.nations[0]
|
||||||
|
|
||||||
async def get_war(kit: pnwkit.QueryKit, id: Union[int, List[int]]) -> Union[pnwkit.War, List[pnwkit.War]]:
|
|
||||||
|
async def get_war(
|
||||||
|
kit: pnwkit.QueryKit, id: Union[int, List[int]]
|
||||||
|
) -> Union[pnwkit.War, List[pnwkit.War]]:
|
||||||
war = await kit.query(
|
war = await kit.query(
|
||||||
"wars",
|
"wars",
|
||||||
{"id": id},
|
{"id": id},
|
||||||
"att_alliance_id, def_alliance_id, id, att_id, def_id, turns_left, winner_id, war_type, att_infra_destroyed, att_infra_destroyed_value, def_infra_destroyed, def_infra_destroyed_value, air_superiority, ground_control, naval_blockade, att_points, def_points, att_resistance, def_resistance"
|
"att_alliance_id, def_alliance_id, id, att_id, def_id, turns_left, winner_id, war_type, att_infra_destroyed, att_infra_destroyed_value, def_infra_destroyed, def_infra_destroyed_value, air_superiority, ground_control, naval_blockade, att_points, def_points, att_resistance, def_resistance",
|
||||||
)
|
)
|
||||||
if isinstance(id, list):
|
if isinstance(id, list):
|
||||||
result = []
|
result = []
|
||||||
@@ -73,4 +81,3 @@ async def get_war(kit: pnwkit.QueryKit, id: Union[int, List[int]]) -> Union[pnwk
|
|||||||
result[result.index(war.id)] = war
|
result[result.index(war.id)] = war
|
||||||
return result
|
return result
|
||||||
return war.wars[0]
|
return war.wars[0]
|
||||||
|
|
||||||
Reference in new issue
Block a user