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