diff --git a/exts/misc.py b/exts/misc.py index f1ef4d6..6d2cddf 100644 --- a/exts/misc.py +++ b/exts/misc.py @@ -1,16 +1,16 @@ -import aiohttp import asyncio import datetime import os import random from typing import Optional +import aiohttp import discord -from discord.ext import commands, tasks import pnwkit import pytz -from pnwkit import Order, OrderBy +from discord.ext import commands, tasks from discord.utils import format_dt +from pnwkit import Order, OrderBy from botclass import Brahmos, CustomCtx @@ -140,7 +140,9 @@ class Misc(commands.Cog): "id, leader_name, nation_name, color, vacation_mode_turns, last_active", ) nations = [ - n for n in res.nations if n.color != "olive" and n.vacation_mode_turns == 0 + n + for n in res.nations + if n.color not in ["olive", "beige"] and n.vacation_mode_turns == 0 ] await channel.send( "> nations not olive:\n" diff --git a/exts/war_monitor.py b/exts/war_monitor.py index ac47369..f825690 100644 --- a/exts/war_monitor.py +++ b/exts/war_monitor.py @@ -4,7 +4,6 @@ import functools import logging import os - import aiohttp import discord import pnwkit @@ -12,7 +11,7 @@ from discord.ext import commands, tasks from botclass import Brahmos, CustomCtx from utils.emojis import Emojis -from utils.funcs import format_count, timeline_button, get_nation, get_war +from utils.funcs import format_count, get_nation, get_war, timeline_button ALLIANCE_ID = 10177 GUILD = 1353930666311421952 @@ -201,8 +200,8 @@ class WarMonitor(commands.Cog): # create war channel for defensive wars await self.defense_handler(war) - async def get_war_channel(self, id: int) -> discord.TextChannel: - id = str(id) + async def get_war_channel(self, ch_id) -> discord.TextChannel | None: + ch_id = str(ch_id) categories = [await self.bot.fetch_channel(cat) for cat in CATEGORIES] channels = [ch for cat in categories for ch in cat.text_channels] channel = [c for c in channels if id in c.name] @@ -512,10 +511,11 @@ class WarMonitor(commands.Cog): async def archive(self, ctx: CustomCtx): categories = [await self.bot.fetch_channel(cat) for cat in CATEGORIES] channels = [ch for cat in categories for ch in cat.text_channels] - if ctx.channel not in channels: - await ctx.send(f"this command only works inside {category.name}") - return archive = await self.bot.fetch_channel(ARCHIVE_CATEGORY) + + if ctx.channel not in channels: + await ctx.send(f"this command only works inside {archive.name}") + return if len(archive.text_channels) == 50: await ctx.send( "> hit channel limit in archive, please delete some channels first" @@ -549,7 +549,7 @@ class WarMonitor(commands.Cog): await ctx.channel.delete() @commands.command() - @commands.has_permissions(administrator=True) + @commands.has_any_role("The Croak Council", "Government", "Military Affairs [MA]") async def delall(self, ctx: CustomCtx): category = await self.bot.fetch_channel(ARCHIVE_CATEGORY) if ctx.channel not in category.text_channels: @@ -561,10 +561,12 @@ class WarMonitor(commands.Cog): except Exception as e: await ctx.send(f"failed to delete channel: {e}") + @commands.has_any_role("The Croak Council", "Government", "Military Affairs [MA]") @commands.command() async def monitored(self, ctx: CustomCtx): await ctx.send(self.monitored_wars) + @commands.has_any_role("The Croak Council", "Government", "Military Affairs [MA]") @commands.command() async def monitor(self, ctx: CustomCtx, id: int): self.monitored_wars.append(id)