mirror of
https://github.com/brandons209/Red-bot-Cogs.git
synced 2024-05-18 03:12:57 +12:00
black reformat
This commit is contained in:
parent
e2dd8fed2a
commit
d81401cac5
|
@ -167,7 +167,6 @@ class ActivityLogger(commands.Cog):
|
|||
prefixes.extend(curr)
|
||||
self.cache[ctx.guild.id]["prefixes"] = curr
|
||||
|
||||
|
||||
@commands.command(aliases=["uinfo"])
|
||||
@commands.guild_only()
|
||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||
|
@ -1093,7 +1092,7 @@ class ActivityLogger(commands.Cog):
|
|||
stats["total_msg"] += 1
|
||||
if len(message.content) > 0:
|
||||
for prefix in self.cache[message.guild.id]["prefixes"]:
|
||||
if prefix == message.content[:len(prefix)]:
|
||||
if prefix == message.content[: len(prefix)]:
|
||||
stats["bot_cmd"] += 1
|
||||
break
|
||||
else:
|
||||
|
@ -1593,7 +1592,7 @@ class ActivityLogger(commands.Cog):
|
|||
msg = "Voice channel leave: {0} (id {0.id})"
|
||||
|
||||
async with self.config.member(member).stats() as stats:
|
||||
if stats["last_vc_time"]: # incase someone joins when bot is offline
|
||||
if stats["last_vc_time"]: # incase someone joins when bot is offline
|
||||
stats["vc_time_sec"] += time.time() - stats["last_vc_time"]
|
||||
stats["last_vc_time"] = None
|
||||
|
||||
|
|
|
@ -82,7 +82,11 @@ class EconomyTrickle(commands.Cog):
|
|||
|
||||
def vpred(mem: discord.Member):
|
||||
with contextlib.suppress(AttributeError):
|
||||
return len(mem.voice.channel.members) > voice_mem and mem.voice.channel.id not in data["blacklist"] and not mem.bot
|
||||
return (
|
||||
len(mem.voice.channel.members) > voice_mem
|
||||
and mem.voice.channel.id not in data["blacklist"]
|
||||
and not mem.bot
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
|
@ -91,7 +95,11 @@ class EconomyTrickle(commands.Cog):
|
|||
|
||||
def vpred(mem: discord.Member):
|
||||
with contextlib.suppress(AttributeError):
|
||||
return len(mem.voice.channel.members) > voice_mem and mem.voice.channel.id in data["whitelist"] and not mem.bot
|
||||
return (
|
||||
len(mem.voice.channel.members) > voice_mem
|
||||
and mem.voice.channel.id in data["whitelist"]
|
||||
and not mem.bot
|
||||
)
|
||||
|
||||
has_active_message = set(self.recordhandler.get_active_for_guild(guild=guild, after=after, message_check=mpred))
|
||||
|
||||
|
|
|
@ -47,7 +47,12 @@ class MoreAdmin(commands.Cog):
|
|||
self.bot = bot
|
||||
self.config = Config.get_conf(self, identifier=213438438248, force_registration=True)
|
||||
|
||||
default_guild = {"user_count_channel": None, "sus_user_channel": None, "sus_user_threshold": None, "prefixes": []}
|
||||
default_guild = {
|
||||
"user_count_channel": None,
|
||||
"sus_user_channel": None,
|
||||
"sus_user_threshold": None,
|
||||
"prefixes": [],
|
||||
}
|
||||
|
||||
default_role = {"addable": []} # role ids who can add this role
|
||||
self.config.register_role(**default_role)
|
||||
|
@ -98,7 +103,7 @@ class MoreAdmin(commands.Cog):
|
|||
skip = False
|
||||
if include_bot_commands:
|
||||
for prefix in prefixes:
|
||||
if message.content and prefix == message.content[:len(prefix)]:
|
||||
if message.content and prefix == message.content[: len(prefix)]:
|
||||
skip = True
|
||||
break
|
||||
|
||||
|
@ -391,7 +396,15 @@ class MoreAdmin(commands.Cog):
|
|||
@commands.command(name="purge")
|
||||
@checks.admin_or_permissions(administrator=True)
|
||||
@checks.bot_has_permissions(kick_members=True)
|
||||
async def purge(self, ctx, role: discord.Role, check_messages: bool = True, include_bot_commands: bool = False, *, threshold: str = None):
|
||||
async def purge(
|
||||
self,
|
||||
ctx,
|
||||
role: discord.Role,
|
||||
check_messages: bool = True,
|
||||
include_bot_commands: bool = False,
|
||||
*,
|
||||
threshold: str = None,
|
||||
):
|
||||
"""
|
||||
Purge inactive users with role.
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from .nitroemoji import NitroEmoji
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
n = NitroEmoji(bot)
|
||||
await n.initialize()
|
||||
|
|
|
@ -12,16 +12,12 @@ class NitroEmoji(commands.Cog):
|
|||
"""
|
||||
Reward nitro boosters with a custom emoji.
|
||||
"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.config = Config.get_conf(self, identifier=123859659843, force_registration=True)
|
||||
default_guild = {
|
||||
"channel": None,
|
||||
"disabled": False
|
||||
}
|
||||
default_member = {
|
||||
"emojis": []
|
||||
}
|
||||
default_guild = {"channel": None, "disabled": False}
|
||||
default_member = {"emojis": []}
|
||||
self.config.register_guild(**default_guild)
|
||||
self.config.register_member(**default_member)
|
||||
|
||||
|
@ -50,7 +46,6 @@ class NitroEmoji(commands.Cog):
|
|||
emoji = discord.utils.get(guild.emojis, name=name)
|
||||
return emoji
|
||||
|
||||
|
||||
async def add_emoji(self, member, name, attachment_or_url, reason=None):
|
||||
path = str(cog_data_path(cog_instance=self))
|
||||
path = os.path.join(path, str(member.id) + name)
|
||||
|
@ -148,7 +143,6 @@ class NitroEmoji(commands.Cog):
|
|||
await self.config.guild(ctx.guild).disabled.set(on_off)
|
||||
await ctx.tick()
|
||||
|
||||
|
||||
@commands.group(name="nitroemoji")
|
||||
@checks.bot_has_permissions(manage_emojis=True)
|
||||
async def nitroemoji(self, ctx):
|
||||
|
@ -184,14 +178,15 @@ class NitroEmoji(commands.Cog):
|
|||
except PIL.UnidentifiedImageError:
|
||||
await ctx.send("That is not a valid picture! Pictures must be in PNG, JPEG, or GIF format.")
|
||||
except:
|
||||
await ctx.send("Something went wrong, make sure to add a valid picture (PNG, JPG, or GIF) of the right size (256KB) and a valid name.")
|
||||
await ctx.send(
|
||||
"Something went wrong, make sure to add a valid picture (PNG, JPG, or GIF) of the right size (256KB) and a valid name."
|
||||
)
|
||||
return
|
||||
elif not boosts:
|
||||
await ctx.send("Sorry, you need to be a nitro booster to add an emoji!")
|
||||
elif curr:
|
||||
await ctx.send("You already have a custom emoji, please delete it first before adding another one.")
|
||||
|
||||
|
||||
@nitroemoji.command(name="rem")
|
||||
async def nitroemoji_rem(self, ctx, name: str):
|
||||
"""
|
||||
|
@ -208,7 +203,6 @@ class NitroEmoji(commands.Cog):
|
|||
else:
|
||||
await ctx.send(warning("Emoji not found."))
|
||||
|
||||
|
||||
@nitroemoji.command(name="list")
|
||||
async def nitroemoji_list(self, ctx):
|
||||
"""
|
||||
|
@ -229,7 +223,6 @@ class NitroEmoji(commands.Cog):
|
|||
for page in pagify(msg):
|
||||
await ctx.send(page)
|
||||
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_member_update(self, before, after):
|
||||
# check if they stopped boosting
|
||||
|
|
|
@ -14,7 +14,12 @@ from redbot.core.config import Config
|
|||
from redbot.core.utils.chat_formatting import box, pagify, warning, humanize_list
|
||||
|
||||
from .events import EventMixin
|
||||
from .exceptions import RoleManagementException, PermissionOrHierarchyException, MissingRequirementsException, ConflictingRoleException
|
||||
from .exceptions import (
|
||||
RoleManagementException,
|
||||
PermissionOrHierarchyException,
|
||||
MissingRequirementsException,
|
||||
ConflictingRoleException,
|
||||
)
|
||||
from .massmanager import MassManagementMixin
|
||||
from .utils import UtilMixin, variation_stripper_re, parse_timedelta, parse_seconds
|
||||
|
||||
|
@ -43,6 +48,7 @@ MIN_SUB_TIME = 3600
|
|||
SLEEP_TIME = 300
|
||||
MAX_EMBED = 25
|
||||
|
||||
|
||||
class RoleManagement(
|
||||
UtilMixin, MassManagementMixin, EventMixin, commands.Cog, metaclass=CompositeMetaClass,
|
||||
):
|
||||
|
@ -814,7 +820,11 @@ class RoleManagement(
|
|||
embed.add_field(
|
||||
name=f"__**{i+1}. {role.name}**__",
|
||||
value="%s%s%s"
|
||||
% ((f"Cost: {cost}" if cost else "Free"), (f", every {parse_seconds(sub)}" if sub else ""), (f"\nunique groups: `{groups}`" if groups else ""))
|
||||
% (
|
||||
(f"Cost: {cost}" if cost else "Free"),
|
||||
(f", every {parse_seconds(sub)}" if sub else ""),
|
||||
(f"\nunique groups: `{groups}`" if groups else ""),
|
||||
),
|
||||
)
|
||||
i += 1
|
||||
if i % MAX_EMBED == 0:
|
||||
|
@ -850,7 +860,9 @@ class RoleManagement(
|
|||
except ConflictingRoleException as e:
|
||||
roles = [r for r in ctx.guild.roles if r in e.conflicts]
|
||||
plural = "are" if len(roles) > 1 else "is"
|
||||
await ctx.send(f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}")
|
||||
await ctx.send(
|
||||
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
||||
)
|
||||
else:
|
||||
if not eligible:
|
||||
return await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!")
|
||||
|
@ -882,7 +894,9 @@ class RoleManagement(
|
|||
|
||||
if remove:
|
||||
plural = "s" if len(remove) > 1 else ""
|
||||
await ctx.send(f"Removed `{humanize_list([r.name for r in remove])}` role{plural} since they are exclusive to the role you added.")
|
||||
await ctx.send(
|
||||
f"Removed `{humanize_list([r.name for r in remove])}` role{plural} since they are exclusive to the role you added."
|
||||
)
|
||||
await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove)
|
||||
await self.dm_user(ctx, role)
|
||||
await ctx.tick()
|
||||
|
@ -914,7 +928,9 @@ class RoleManagement(
|
|||
print(e.conflicts)
|
||||
roles = [r for r in ctx.guild.roles if r in e.conflicts]
|
||||
plural = "are" if len(roles) > 1 else "is"
|
||||
await ctx.send(f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}")
|
||||
await ctx.send(
|
||||
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
||||
)
|
||||
else:
|
||||
if not eligible:
|
||||
await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!")
|
||||
|
@ -926,7 +942,9 @@ class RoleManagement(
|
|||
else:
|
||||
if remove:
|
||||
plural = "s" if len(remove) > 1 else ""
|
||||
await ctx.send(f"Removed `{humanize_list([r.name for r in remove])}` role{plural} since they are exclusive to the role you added.")
|
||||
await ctx.send(
|
||||
f"Removed `{humanize_list([r.name for r in remove])}` role{plural} since they are exclusive to the role you added."
|
||||
)
|
||||
await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove)
|
||||
await self.dm_user(ctx, role)
|
||||
await ctx.tick()
|
||||
|
|
Loading…
Reference in a new issue