The 100-character line reckoning. Reformatted every file that needed it
This commit is contained in:
parent
d7c9742ce5
commit
7a17410514
22 changed files with 236 additions and 86 deletions
|
@ -4,7 +4,7 @@ import logging
|
||||||
from dis_snek import Intents, Snake
|
from dis_snek import Intents, Snake
|
||||||
from mongoengine import connect
|
from mongoengine import connect
|
||||||
|
|
||||||
from jarvis import logo # noqa: F401
|
# from jarvis import logo # noqa: F401
|
||||||
from jarvis import tasks, utils
|
from jarvis import tasks, utils
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.events import guild, member, message
|
from jarvis.events import guild, member, message
|
||||||
|
@ -56,7 +56,7 @@ def run() -> None:
|
||||||
|
|
||||||
print(
|
print(
|
||||||
" https://discord.com/api/oauth2/authorize?client_id="
|
" https://discord.com/api/oauth2/authorize?client_id="
|
||||||
+ "{}&permissions=8&scope=bot%20applications.commands".format(jconfig.client_id) # noqa: W503
|
"{}&permissions=8&scope=bot%20applications.commands".format(jconfig.client_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
jarvis.max_messages = jconfig.max_messages
|
jarvis.max_messages = jconfig.max_messages
|
||||||
|
|
|
@ -90,8 +90,12 @@ class BanCog(CacheCog):
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@slash_command(name="ban", description="Ban a user")
|
@slash_command(name="ban", description="Ban a user")
|
||||||
@slash_option(name="user", description="User to ban", option_type=OptionTypes.USER, required=True)
|
@slash_option(
|
||||||
@slash_option(name="reason", description="Ban reason", option_type=OptionTypes.STRING, required=True)
|
name="user", description="User to ban", option_type=OptionTypes.USER, required=True
|
||||||
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="reason", description="Ban reason", option_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
@slash_option(
|
@slash_option(
|
||||||
name="btype",
|
name="btype",
|
||||||
description="Ban type",
|
description="Ban type",
|
||||||
|
@ -181,8 +185,12 @@ class BanCog(CacheCog):
|
||||||
await self.discord_apply_ban(ctx, reason, user, duration, active, fields, mtype)
|
await self.discord_apply_ban(ctx, reason, user, duration, active, fields, mtype)
|
||||||
|
|
||||||
@slash_command(name="unban", description="Unban a user")
|
@slash_command(name="unban", description="Unban a user")
|
||||||
@slash_option(name="user", description="User to unban", option_type=OptionTypes.STRING, required=True)
|
@slash_option(
|
||||||
@slash_option(name="reason", description="Unban reason", option_type=OptionTypes.STRING, required=True)
|
name="user", description="User to unban", option_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="reason", description="Unban reason", option_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
@admin_or_permissions(Permissions.BAN_MEMBERS)
|
@admin_or_permissions(Permissions.BAN_MEMBERS)
|
||||||
async def _unban(
|
async def _unban(
|
||||||
self,
|
self,
|
||||||
|
@ -219,9 +227,14 @@ class BanCog(CacheCog):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
active_bans = []
|
active_bans = []
|
||||||
for ban in bans:
|
for ban in bans:
|
||||||
active_bans.append("{0} ({1}): {2}".format(ban.user.username, ban.user.id, ban.reason))
|
active_bans.append(
|
||||||
|
"{0} ({1}): {2}".format(ban.user.username, ban.user.id, ban.reason)
|
||||||
|
)
|
||||||
ab_message = "\n".join(active_bans)
|
ab_message = "\n".join(active_bans)
|
||||||
message = f"More than one result. Please use one of the following IDs:\n```{ab_message}\n```"
|
message = (
|
||||||
|
"More than one result. "
|
||||||
|
f"Please use one of the following IDs:\n```{ab_message}\n```"
|
||||||
|
)
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -263,9 +276,13 @@ class BanCog(CacheCog):
|
||||||
admin=ctx.author.id,
|
admin=ctx.author.id,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
).save()
|
).save()
|
||||||
await ctx.send("Unable to find user in Discord, " + "but removed entry from database.")
|
await ctx.send(
|
||||||
|
"Unable to find user in Discord, " + "but removed entry from database."
|
||||||
|
)
|
||||||
|
|
||||||
@slash_command(name="bans", description="User bans", sub_cmd_name="list", sub_cmd_description="List bans")
|
@slash_command(
|
||||||
|
name="bans", description="User bans", sub_cmd_name="list", sub_cmd_description="List bans"
|
||||||
|
)
|
||||||
@slash_option(
|
@slash_option(
|
||||||
name="btype",
|
name="btype",
|
||||||
description="Ban type",
|
description="Ban type",
|
||||||
|
@ -356,7 +373,7 @@ class BanCog(CacheCog):
|
||||||
pages.append(embed)
|
pages.append(embed)
|
||||||
else:
|
else:
|
||||||
for i in range(0, len(bans), 5):
|
for i in range(0, len(bans), 5):
|
||||||
embed = build_embed(title=title, description="", fields=fields[i : i + 5]) # noqa: E203
|
embed = build_embed(title=title, description="", fields=fields[i : i + 5])
|
||||||
embed.set_thumbnail(url=ctx.guild.icon_url)
|
embed.set_thumbnail(url=ctx.guild.icon_url)
|
||||||
pages.append(embed)
|
pages.append(embed)
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,12 @@ class KickCog(Scale):
|
||||||
"""J.A.R.V.I.S. KickCog."""
|
"""J.A.R.V.I.S. KickCog."""
|
||||||
|
|
||||||
@slash_command(name="kick", description="Kick a user")
|
@slash_command(name="kick", description="Kick a user")
|
||||||
@slash_option(name="user", description="User to kick", option_type=OptionTypes.USER, required=True)
|
@slash_option(
|
||||||
@slash_option(name="reason", description="Kick reason", option_type=OptionTypes.STRING, required=True)
|
name="user", description="User to kick", option_type=OptionTypes.USER, required=True
|
||||||
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="reason", description="Kick reason", option_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
@admin_or_permissions(Permissions.BAN_MEMBERS)
|
@admin_or_permissions(Permissions.BAN_MEMBERS)
|
||||||
async def _kick(self, ctx: InteractionContext, user: User, reason: str) -> None:
|
async def _kick(self, ctx: InteractionContext, user: User, reason: str) -> None:
|
||||||
if not user or user == ctx.author:
|
if not user or user == ctx.author:
|
||||||
|
|
|
@ -22,7 +22,9 @@ class MuteCog(Scale):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@slash_command(name="mute", description="Mute a user")
|
@slash_command(name="mute", description="Mute a user")
|
||||||
@slash_option(name="user", description="User to mute", option_type=OptionTypes.USER, required=True)
|
@slash_option(
|
||||||
|
name="user", description="User to mute", option_type=OptionTypes.USER, required=True
|
||||||
|
)
|
||||||
@slash_option(
|
@slash_option(
|
||||||
name="reason",
|
name="reason",
|
||||||
description="Reason for mute",
|
description="Reason for mute",
|
||||||
|
@ -47,7 +49,9 @@ class MuteCog(Scale):
|
||||||
SlashCommandChoice(name="Week(s)", value=604800),
|
SlashCommandChoice(name="Week(s)", value=604800),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@admin_or_permissions(Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS)
|
@admin_or_permissions(
|
||||||
|
Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS
|
||||||
|
)
|
||||||
async def _timeout(
|
async def _timeout(
|
||||||
self, ctx: InteractionContext, user: Member, reason: str, time: int = 1, scale: int = 60
|
self, ctx: InteractionContext, user: Member, reason: str, time: int = 1, scale: int = 60
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -83,10 +87,17 @@ class MuteCog(Scale):
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@slash_command(name="unmute", description="Unmute a user")
|
@slash_command(name="unmute", description="Unmute a user")
|
||||||
@slash_option(name="user", description="User to unmute", option_type=OptionTypes.USER, required=True)
|
@slash_option(
|
||||||
@admin_or_permissions(Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS)
|
name="user", description="User to unmute", option_type=OptionTypes.USER, required=True
|
||||||
|
)
|
||||||
|
@admin_or_permissions(
|
||||||
|
Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS
|
||||||
|
)
|
||||||
async def _unmute(self, ctx: InteractionContext, user: Member) -> None:
|
async def _unmute(self, ctx: InteractionContext, user: Member) -> None:
|
||||||
if not user.communication_disabled_until or user.communication_disabled_until < datetime.now():
|
if (
|
||||||
|
not user.communication_disabled_until
|
||||||
|
or user.communication_disabled_until < datetime.now() # noqa: W503
|
||||||
|
):
|
||||||
await ctx.send("User is not muted", hidden=True)
|
await ctx.send("User is not muted", hidden=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,9 @@ class PurgeCog(commands.Cog):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@admin_or_permissions(manage_messages=True)
|
@admin_or_permissions(manage_messages=True)
|
||||||
async def _autopurge_add(self, ctx: SlashContext, channel: TextChannel, delay: int = 30) -> None:
|
async def _autopurge_add(
|
||||||
|
self, ctx: SlashContext, channel: TextChannel, delay: int = 30
|
||||||
|
) -> None:
|
||||||
if not isinstance(channel, TextChannel):
|
if not isinstance(channel, TextChannel):
|
||||||
await ctx.send("Channel must be a TextChannel", hidden=True)
|
await ctx.send("Channel must be a TextChannel", hidden=True)
|
||||||
return
|
return
|
||||||
|
|
|
@ -97,7 +97,10 @@ class RolepingCog(CacheCog):
|
||||||
role = ctx.guild.get_role(roleping.role)
|
role = ctx.guild.get_role(roleping.role)
|
||||||
bypass_roles = list(filter(lambda x: x.id in roleping.bypass["roles"], ctx.guild.roles))
|
bypass_roles = list(filter(lambda x: x.id in roleping.bypass["roles"], ctx.guild.roles))
|
||||||
bypass_roles = [r.mention or "||`[redacted]`||" for r in bypass_roles]
|
bypass_roles = [r.mention or "||`[redacted]`||" for r in bypass_roles]
|
||||||
bypass_users = [ctx.guild.get_member(u).mention or "||`[redacted]`||" for u in roleping.bypass["users"]]
|
bypass_users = [
|
||||||
|
ctx.guild.get_member(u).mention or "||`[redacted]`||"
|
||||||
|
for u in roleping.bypass["users"]
|
||||||
|
]
|
||||||
bypass_roles = bypass_roles or ["None"]
|
bypass_roles = bypass_roles or ["None"]
|
||||||
bypass_users = bypass_users or ["None"]
|
bypass_users = bypass_users or ["None"]
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
|
@ -242,7 +245,8 @@ class RolepingCog(CacheCog):
|
||||||
|
|
||||||
if len(roleping.bypass["roles"]) == 10:
|
if len(roleping.bypass["roles"]) == 10:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Already have 10 roles in bypass. Please consider consolidating roles for roleping bypass",
|
"Already have 10 roles in bypass. "
|
||||||
|
"Please consider consolidating roles for roleping bypass",
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
@ -323,7 +327,8 @@ class RolepingCog(CacheCog):
|
||||||
|
|
||||||
if len(roleping.bypass["roles"]) == 10:
|
if len(roleping.bypass["roles"]) == 10:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Already have 10 roles in bypass. Please consider consolidating roles for roleping bypass",
|
"Already have 10 roles in bypass. "
|
||||||
|
"Please consider consolidating roles for roleping bypass",
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
|
@ -116,7 +116,9 @@ class WarningCog(CacheCog):
|
||||||
user=user.id,
|
user=user.id,
|
||||||
guild=ctx.guild.id,
|
guild=ctx.guild.id,
|
||||||
).order_by("-created_at")
|
).order_by("-created_at")
|
||||||
active_warns = Warning.objects(user=user.id, guild=ctx.guild.id, active=True).order_by("-created_at")
|
active_warns = Warning.objects(user=user.id, guild=ctx.guild.id, active=True).order_by(
|
||||||
|
"-created_at"
|
||||||
|
)
|
||||||
|
|
||||||
pages = []
|
pages = []
|
||||||
if active:
|
if active:
|
||||||
|
@ -146,8 +148,10 @@ class WarningCog(CacheCog):
|
||||||
for i in range(0, len(fields), 5):
|
for i in range(0, len(fields), 5):
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Warnings",
|
title="Warnings",
|
||||||
description=f"{warnings.count()} total | {active_warns.count()} currently active",
|
description=(
|
||||||
fields=fields[i : i + 5], # noqa: E203
|
f"{warnings.count()} total | {active_warns.count()} currently active"
|
||||||
|
),
|
||||||
|
fields=fields[i : i + 5],
|
||||||
)
|
)
|
||||||
embed.set_author(
|
embed.set_author(
|
||||||
name=user.name + "#" + user.discriminator,
|
name=user.name + "#" + user.discriminator,
|
||||||
|
@ -171,8 +175,10 @@ class WarningCog(CacheCog):
|
||||||
for i in range(0, len(fields), 5):
|
for i in range(0, len(fields), 5):
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Warnings",
|
title="Warnings",
|
||||||
description=f"{warnings.count()} total | {active_warns.count()} currently active",
|
description=(
|
||||||
fields=fields[i : i + 5], # noqa: E203
|
f"{warnings.count()} total | {active_warns.count()} currently active"
|
||||||
|
),
|
||||||
|
fields=fields[i : i + 5],
|
||||||
)
|
)
|
||||||
embed.set_author(
|
embed.set_author(
|
||||||
name=user.name + "#" + user.discriminator,
|
name=user.name + "#" + user.discriminator,
|
||||||
|
|
|
@ -108,7 +108,9 @@ class AutoReactCog(commands.Cog):
|
||||||
return
|
return
|
||||||
exists = Autoreact.objects(guild=ctx.guild.id, channel=channel.id).first()
|
exists = Autoreact.objects(guild=ctx.guild.id, channel=channel.id).first()
|
||||||
if not exists:
|
if not exists:
|
||||||
await ctx.send(f"Please create autoreact first with /autoreact create {channel.mention}")
|
await ctx.send(
|
||||||
|
f"Please create autoreact first with /autoreact create {channel.mention}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if emote in exists.reactions:
|
if emote in exists.reactions:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
@ -188,7 +190,9 @@ class AutoReactCog(commands.Cog):
|
||||||
return
|
return
|
||||||
message = ""
|
message = ""
|
||||||
if len(exists.reactions) > 0:
|
if len(exists.reactions) > 0:
|
||||||
message = f"Current active autoreacts on {channel.mention}:\n" + "\n".join(exists.reactions)
|
message = f"Current active autoreacts on {channel.mention}:\n" + "\n".join(
|
||||||
|
exists.reactions
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
message = f"No reactions set on {channel.mention}"
|
message = f"No reactions set on {channel.mention}"
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
|
|
|
@ -18,7 +18,7 @@ guild_ids = [578757004059738142, 520021794380447745, 862402786116763668]
|
||||||
|
|
||||||
valid = re.compile(r"[\w\s\-\\/.!@#$%^*()+=<>,\u0080-\U000E0FFF]*")
|
valid = re.compile(r"[\w\s\-\\/.!@#$%^*()+=<>,\u0080-\U000E0FFF]*")
|
||||||
invites = re.compile(
|
invites = re.compile(
|
||||||
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)",
|
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501
|
||||||
flags=re.IGNORECASE,
|
flags=re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,13 +54,19 @@ class CTCCog(CacheCog):
|
||||||
async def _pw(self, ctx: SlashContext, guess: str) -> None:
|
async def _pw(self, ctx: SlashContext, guess: str) -> None:
|
||||||
if len(guess) > 800:
|
if len(guess) > 800:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Listen here, dipshit. Don't be like <@256110768724901889>. Make your guesses < 800 characters.",
|
(
|
||||||
|
"Listen here, dipshit. Don't be like <@256110768724901889>. "
|
||||||
|
"Make your guesses < 800 characters."
|
||||||
|
),
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
elif not valid.fullmatch(guess):
|
elif not valid.fullmatch(guess):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Listen here, dipshit. Don't be like <@256110768724901889>. Make your guesses *readable*.",
|
(
|
||||||
|
"Listen here, dipshit. Don't be like <@256110768724901889>. "
|
||||||
|
"Make your guesses *readable*."
|
||||||
|
),
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
@ -124,7 +130,7 @@ class CTCCog(CacheCog):
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="completethecodetwo.cards guesses",
|
title="completethecodetwo.cards guesses",
|
||||||
description=f"{len(fields)} guesses so far",
|
description=f"{len(fields)} guesses so far",
|
||||||
fields=fields[i : i + 5], # noqa: E203
|
fields=fields[i : i + 5],
|
||||||
url="https://completethecodetwo.cards",
|
url="https://completethecodetwo.cards",
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
||||||
|
|
|
@ -230,7 +230,8 @@ class DbrandCog(commands.Cog):
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Check Shipping Times",
|
title="Check Shipping Times",
|
||||||
description=(
|
description=(
|
||||||
"Country not found.\nYou can [view all shipping " "destinations here](https://dbrand.com/shipping)"
|
"Country not found.\nYou can [view all shipping "
|
||||||
|
"destinations here](https://dbrand.com/shipping)"
|
||||||
),
|
),
|
||||||
fields=[],
|
fields=[],
|
||||||
url="https://dbrand.com/shipping",
|
url="https://dbrand.com/shipping",
|
||||||
|
|
|
@ -18,9 +18,11 @@ from jarvis.utils.field import Field
|
||||||
supported_hashes = {x for x in hashlib.algorithms_guaranteed if "shake" not in x}
|
supported_hashes = {x for x in hashlib.algorithms_guaranteed if "shake" not in x}
|
||||||
|
|
||||||
OID_VERIFY = re.compile(r"^([1-9][0-9]{0,3}|0)(\.([1-9][0-9]{0,3}|0)){5,13}$")
|
OID_VERIFY = re.compile(r"^([1-9][0-9]{0,3}|0)(\.([1-9][0-9]{0,3}|0)){5,13}$")
|
||||||
URL_VERIFY = re.compile(r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+")
|
URL_VERIFY = re.compile(
|
||||||
|
r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"
|
||||||
|
)
|
||||||
DN_VERIFY = re.compile(
|
DN_VERIFY = re.compile(
|
||||||
r"^(?:(?P<cn>CN=(?P<name>[^,]*)),)?(?:(?P<path>(?:(?:CN|OU)=[^,]+,?)+),)?(?P<domain>(?:DC=[^,]+,?)+)$"
|
r"^(?:(?P<cn>CN=(?P<name>[^,]*)),)?(?:(?P<path>(?:(?:CN|OU)=[^,]+,?)+),)?(?P<domain>(?:DC=[^,]+,?)+)$" # noqa: E501
|
||||||
)
|
)
|
||||||
ULID_VERIFY = re.compile(r"^[0-9a-z]{26}$", re.IGNORECASE)
|
ULID_VERIFY = re.compile(r"^[0-9a-z]{26}$", re.IGNORECASE)
|
||||||
UUID_VERIFY = re.compile(
|
UUID_VERIFY = re.compile(
|
||||||
|
@ -29,7 +31,7 @@ UUID_VERIFY = re.compile(
|
||||||
)
|
)
|
||||||
|
|
||||||
invites = re.compile(
|
invites = re.compile(
|
||||||
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)",
|
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501
|
||||||
flags=re.IGNORECASE,
|
flags=re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ def hash_obj(hash: Any, data: Union[str, bytes], text: bool = True) -> str:
|
||||||
BSIZE = 65536
|
BSIZE = 65536
|
||||||
block_idx = 0
|
block_idx = 0
|
||||||
while block_idx * BSIZE < len(data):
|
while block_idx * BSIZE < len(data):
|
||||||
block = data[BSIZE * block_idx : BSIZE * (block_idx + 1)] # noqa: E203
|
block = data[BSIZE * block_idx : BSIZE * (block_idx + 1)]
|
||||||
hash.update(block)
|
hash.update(block)
|
||||||
block_idx += 1
|
block_idx += 1
|
||||||
return hash.hexdigest()
|
return hash.hexdigest()
|
||||||
|
@ -253,7 +255,9 @@ class DevCog(commands.Cog):
|
||||||
)
|
)
|
||||||
@commands.cooldown(1, 30, commands.BucketType.channel)
|
@commands.cooldown(1, 30, commands.BucketType.channel)
|
||||||
async def _cloc(self, ctx: SlashContext) -> None:
|
async def _cloc(self, ctx: SlashContext) -> None:
|
||||||
output = subprocess.check_output(["tokei", "-C", "--sort", "code"]).decode("UTF-8") # noqa: S603, S607
|
output = subprocess.check_output( # noqa: S603, S607
|
||||||
|
["tokei", "-C", "--sort", "code"]
|
||||||
|
).decode("UTF-8")
|
||||||
await ctx.send(f"```\n{output}\n```")
|
await ctx.send(f"```\n{output}\n```")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ class ErrorHandlerCog(commands.Cog):
|
||||||
return
|
return
|
||||||
elif isinstance(error, commands.errors.CommandOnCooldown):
|
elif isinstance(error, commands.errors.CommandOnCooldown):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Command on cooldown. " + f"Please wait {error.retry_after:0.2f}s before trying again",
|
"Command on cooldown. "
|
||||||
|
f"Please wait {error.retry_after:0.2f}s before trying again",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await ctx.send(f"Error processing command:\n```{error}```")
|
await ctx.send(f"Error processing command:\n```{error}```")
|
||||||
|
@ -29,13 +30,16 @@ class ErrorHandlerCog(commands.Cog):
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_slash_command_error(self, ctx: SlashContext, error: Exception) -> None:
|
async def on_slash_command_error(self, ctx: SlashContext, error: Exception) -> None:
|
||||||
"""discord_slash on_slash_command_error override."""
|
"""discord_slash on_slash_command_error override."""
|
||||||
if isinstance(error, commands.errors.MissingPermissions) or isinstance(error, commands.errors.CheckFailure):
|
if isinstance(error, commands.errors.MissingPermissions) or isinstance(
|
||||||
|
error, commands.errors.CheckFailure
|
||||||
|
):
|
||||||
await ctx.send("I'm afraid I can't let you do that.", hidden=True)
|
await ctx.send("I'm afraid I can't let you do that.", hidden=True)
|
||||||
elif isinstance(error, commands.errors.CommandNotFound):
|
elif isinstance(error, commands.errors.CommandNotFound):
|
||||||
return
|
return
|
||||||
elif isinstance(error, commands.errors.CommandOnCooldown):
|
elif isinstance(error, commands.errors.CommandOnCooldown):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Command on cooldown. " + f"Please wait {error.retry_after:0.2f}s before trying again",
|
"Command on cooldown. "
|
||||||
|
f"Please wait {error.retry_after:0.2f}s before trying again",
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -46,7 +46,9 @@ class GitlabCog(CacheCog):
|
||||||
else:
|
else:
|
||||||
assignee = "None"
|
assignee = "None"
|
||||||
|
|
||||||
created_at = datetime.strptime(issue.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
created_at = datetime.strptime(issue.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
|
|
||||||
labels = issue.labels
|
labels = issue.labels
|
||||||
if labels:
|
if labels:
|
||||||
|
@ -62,7 +64,9 @@ class GitlabCog(CacheCog):
|
||||||
color = self.project.labels.get(issue.labels[0]).color
|
color = self.project.labels.get(issue.labels[0]).color
|
||||||
fields.append(Field(name="Created At", value=created_at))
|
fields.append(Field(name="Created At", value=created_at))
|
||||||
if issue.state == "closed":
|
if issue.state == "closed":
|
||||||
closed_at = datetime.strptime(issue.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
closed_at = datetime.strptime(issue.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
fields.append(Field(name="Closed At", value=closed_at))
|
fields.append(Field(name="Closed At", value=closed_at))
|
||||||
if issue.milestone:
|
if issue.milestone:
|
||||||
fields.append(
|
fields.append(
|
||||||
|
@ -86,7 +90,9 @@ class GitlabCog(CacheCog):
|
||||||
icon_url=issue.author["avatar_url"],
|
icon_url=issue.author["avatar_url"],
|
||||||
url=issue.author["web_url"],
|
url=issue.author["web_url"],
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
embed.set_thumbnail(
|
||||||
|
url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png"
|
||||||
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@cog_ext.cog_subcommand(
|
@cog_ext.cog_subcommand(
|
||||||
|
@ -110,7 +116,9 @@ class GitlabCog(CacheCog):
|
||||||
await ctx.send("Milestone does not exist.", hidden=True)
|
await ctx.send("Milestone does not exist.", hidden=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
created_at = datetime.strptime(milestone.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
created_at = datetime.strptime(milestone.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
Field(
|
Field(
|
||||||
|
@ -143,7 +151,9 @@ class GitlabCog(CacheCog):
|
||||||
url="https://git.zevaryx.com/jarvis",
|
url="https://git.zevaryx.com/jarvis",
|
||||||
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
embed.set_thumbnail(
|
||||||
|
url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png"
|
||||||
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@cog_ext.cog_subcommand(
|
@cog_ext.cog_subcommand(
|
||||||
|
@ -172,7 +182,9 @@ class GitlabCog(CacheCog):
|
||||||
else:
|
else:
|
||||||
assignee = "None"
|
assignee = "None"
|
||||||
|
|
||||||
created_at = datetime.strptime(mr.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
created_at = datetime.strptime(mr.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
|
|
||||||
labels = mr.labels
|
labels = mr.labels
|
||||||
if labels:
|
if labels:
|
||||||
|
@ -191,10 +203,14 @@ class GitlabCog(CacheCog):
|
||||||
color = "#00FFEE"
|
color = "#00FFEE"
|
||||||
fields.append(Field(name="Created At", value=created_at))
|
fields.append(Field(name="Created At", value=created_at))
|
||||||
if mr.state == "merged":
|
if mr.state == "merged":
|
||||||
merged_at = datetime.strptime(mr.merged_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
merged_at = datetime.strptime(mr.merged_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
fields.append(Field(name="Merged At", value=merged_at))
|
fields.append(Field(name="Merged At", value=merged_at))
|
||||||
elif mr.state == "closed":
|
elif mr.state == "closed":
|
||||||
closed_at = datetime.strptime(mr.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
closed_at = datetime.strptime(mr.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
fields.append(Field(name="Closed At", value=closed_at))
|
fields.append(Field(name="Closed At", value=closed_at))
|
||||||
if mr.milestone:
|
if mr.milestone:
|
||||||
fields.append(
|
fields.append(
|
||||||
|
@ -218,7 +234,9 @@ class GitlabCog(CacheCog):
|
||||||
icon_url=mr.author["avatar_url"],
|
icon_url=mr.author["avatar_url"],
|
||||||
url=mr.author["web_url"],
|
url=mr.author["web_url"],
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
embed.set_thumbnail(
|
||||||
|
url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png"
|
||||||
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
def build_embed_page(self, api_list: list, t_state: str, name: str) -> Embed:
|
def build_embed_page(self, api_list: list, t_state: str, name: str) -> Embed:
|
||||||
|
@ -248,7 +266,9 @@ class GitlabCog(CacheCog):
|
||||||
url="https://git.zevaryx.com/jarvis",
|
url="https://git.zevaryx.com/jarvis",
|
||||||
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
embed.set_thumbnail(
|
||||||
|
url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png"
|
||||||
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@cog_ext.cog_subcommand(
|
@cog_ext.cog_subcommand(
|
||||||
|
@ -311,7 +331,7 @@ class GitlabCog(CacheCog):
|
||||||
pages = []
|
pages = []
|
||||||
t_state = t_state[0].upper() + t_state[1:]
|
t_state = t_state[0].upper() + t_state[1:]
|
||||||
for i in range(0, len(issues), 5):
|
for i in range(0, len(issues), 5):
|
||||||
pages.append(self.build_embed_page(issues[i : i + 5], t_state=t_state, name="issue")) # noqa: E203
|
pages.append(self.build_embed_page(issues[i : i + 5], t_state=t_state, name="issue"))
|
||||||
|
|
||||||
paginator = Paginator(
|
paginator = Paginator(
|
||||||
bot=self.bot,
|
bot=self.bot,
|
||||||
|
@ -398,7 +418,9 @@ class GitlabCog(CacheCog):
|
||||||
pages = []
|
pages = []
|
||||||
t_state = t_state[0].upper() + t_state[1:]
|
t_state = t_state[0].upper() + t_state[1:]
|
||||||
for i in range(0, len(merges), 5):
|
for i in range(0, len(merges), 5):
|
||||||
pages.append(self.build_embed_page(merges[i : i + 5], t_state=t_state, name="merge request")) # noqa: E203
|
pages.append(
|
||||||
|
self.build_embed_page(merges[i : i + 5], t_state=t_state, name="merge request")
|
||||||
|
)
|
||||||
|
|
||||||
paginator = Paginator(
|
paginator = Paginator(
|
||||||
bot=self.bot,
|
bot=self.bot,
|
||||||
|
@ -463,7 +485,9 @@ class GitlabCog(CacheCog):
|
||||||
|
|
||||||
pages = []
|
pages = []
|
||||||
for i in range(0, len(milestones), 5):
|
for i in range(0, len(milestones), 5):
|
||||||
pages.append(self.build_embed_page(milestones[i : i + 5], t_state=None, name="milestone")) # noqa: E203
|
pages.append(
|
||||||
|
self.build_embed_page(milestones[i : i + 5], t_state=None, name="milestone")
|
||||||
|
)
|
||||||
|
|
||||||
paginator = Paginator(
|
paginator = Paginator(
|
||||||
bot=self.bot,
|
bot=self.bot,
|
||||||
|
|
|
@ -45,5 +45,7 @@ class ModlogCommandCog(commands.Cog):
|
||||||
name=ctx.author.name,
|
name=ctx.author.name,
|
||||||
icon_url=ctx.author.avatar_url,
|
icon_url=ctx.author.avatar_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{ctx.author.name}#{ctx.author.discriminator} | {ctx.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{ctx.author.name}#{ctx.author.discriminator} | {ctx.author.id}"
|
||||||
|
)
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
|
@ -223,7 +223,9 @@ class ModlogMemberCog(commands.Cog):
|
||||||
desc=f"{before.mention} was verified",
|
desc=f"{before.mention} was verified",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def process_rolechange(self, before: discord.Member, after: discord.Member) -> discord.Embed:
|
async def process_rolechange(
|
||||||
|
self, before: discord.Member, after: discord.Member
|
||||||
|
) -> discord.Embed:
|
||||||
"""Process rolechange event."""
|
"""Process rolechange event."""
|
||||||
await asyncio.sleep(0.5) # Need to wait for audit log
|
await asyncio.sleep(0.5) # Need to wait for audit log
|
||||||
auditlog = await before.guild.audit_logs(
|
auditlog = await before.guild.audit_logs(
|
||||||
|
|
|
@ -47,7 +47,9 @@ class ModlogMessageCog(commands.Cog):
|
||||||
icon_url=before.author.avatar_url,
|
icon_url=before.author.avatar_url,
|
||||||
url=after.jump_url,
|
url=after.jump_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{before.author.name}#{before.author.discriminator} | {before.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{before.author.name}#{before.author.discriminator} | {before.author.id}"
|
||||||
|
)
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
|
@ -100,5 +102,7 @@ class ModlogMessageCog(commands.Cog):
|
||||||
icon_url=message.author.avatar_url,
|
icon_url=message.author.avatar_url,
|
||||||
url=message.jump_url,
|
url=message.jump_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}"
|
||||||
|
)
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
|
@ -129,7 +129,9 @@ class StarboardCog(commands.Cog):
|
||||||
),
|
),
|
||||||
create_option(
|
create_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
description="Channel that has the message, required if different than command message",
|
description=(
|
||||||
|
"Channel that has the message, " "required if different than command message"
|
||||||
|
),
|
||||||
option_type=7,
|
option_type=7,
|
||||||
required=False,
|
required=False,
|
||||||
),
|
),
|
||||||
|
@ -154,7 +156,9 @@ class StarboardCog(commands.Cog):
|
||||||
for starboard in starboards:
|
for starboard in starboards:
|
||||||
channel_list.append(find(lambda x: x.id == starboard.channel, ctx.guild.channels))
|
channel_list.append(find(lambda x: x.id == starboard.channel, ctx.guild.channels))
|
||||||
|
|
||||||
select_channels = [create_select_option(label=x.name, value=str(idx)) for idx, x in enumerate(channel_list)]
|
select_channels = [
|
||||||
|
create_select_option(label=x.name, value=str(idx)) for idx, x in enumerate(channel_list)
|
||||||
|
]
|
||||||
|
|
||||||
select = create_select(
|
select = create_select(
|
||||||
options=select_channels,
|
options=select_channels,
|
||||||
|
@ -303,3 +307,4 @@ class StarboardCog(commands.Cog):
|
||||||
def setup(bot: commands.Bot) -> None:
|
def setup(bot: commands.Bot) -> None:
|
||||||
"""Add StarboardCog to J.A.R.V.I.S."""
|
"""Add StarboardCog to J.A.R.V.I.S."""
|
||||||
bot.add_cog(StarboardCog(bot))
|
bot.add_cog(StarboardCog(bot))
|
||||||
|
bot.add_cog(StarboardCog(bot))
|
||||||
|
|
|
@ -31,7 +31,9 @@ class TwitterCog(commands.Cog):
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
config = get_config()
|
config = get_config()
|
||||||
auth = tweepy.AppAuthHandler(config.twitter["consumer_key"], config.twitter["consumer_secret"])
|
auth = tweepy.AppAuthHandler(
|
||||||
|
config.twitter["consumer_key"], config.twitter["consumer_secret"]
|
||||||
|
)
|
||||||
self.api = tweepy.API(auth)
|
self.api = tweepy.API(auth)
|
||||||
self._tweets.start()
|
self._tweets.start()
|
||||||
self._guild_cache = {}
|
self._guild_cache = {}
|
||||||
|
@ -49,7 +51,9 @@ class TwitterCog(commands.Cog):
|
||||||
logger.error(f"Error with fetching: {e}")
|
logger.error(f"Error with fetching: {e}")
|
||||||
for twitter in twitters:
|
for twitter in twitters:
|
||||||
try:
|
try:
|
||||||
tweets = list(filter(lambda x: x.id > twitter.last_tweet, twitter_data[twitter.handle]))
|
tweets = list(
|
||||||
|
filter(lambda x: x.id > twitter.last_tweet, twitter_data[twitter.handle])
|
||||||
|
)
|
||||||
if tweets:
|
if tweets:
|
||||||
tweets = sorted(tweets, key=lambda x: x.id)
|
tweets = sorted(tweets, key=lambda x: x.id)
|
||||||
if twitter.guild not in self._guild_cache:
|
if twitter.guild not in self._guild_cache:
|
||||||
|
@ -57,7 +61,9 @@ class TwitterCog(commands.Cog):
|
||||||
guild = self._guild_cache[twitter.guild]
|
guild = self._guild_cache[twitter.guild]
|
||||||
if twitter.channel not in self._channel_cache:
|
if twitter.channel not in self._channel_cache:
|
||||||
channels = await guild.fetch_channels()
|
channels = await guild.fetch_channels()
|
||||||
self._channel_cache[twitter.channel] = find(lambda x: x.id == twitter.channel, channels)
|
self._channel_cache[twitter.channel] = find(
|
||||||
|
lambda x: x.id == twitter.channel, channels
|
||||||
|
)
|
||||||
channel = self._channel_cache[twitter.channel]
|
channel = self._channel_cache[twitter.channel]
|
||||||
for tweet in tweets:
|
for tweet in tweets:
|
||||||
retweet = "retweeted_status" in tweet.__dict__
|
retweet = "retweeted_status" in tweet.__dict__
|
||||||
|
@ -66,7 +72,9 @@ class TwitterCog(commands.Cog):
|
||||||
timestamp = int(tweet.created_at.timestamp())
|
timestamp = int(tweet.created_at.timestamp())
|
||||||
url = f"https://twitter.com/{twitter.handle}/status/{tweet.id}"
|
url = f"https://twitter.com/{twitter.handle}/status/{tweet.id}"
|
||||||
verb = "re" if retweet else ""
|
verb = "re" if retweet else ""
|
||||||
await channel.send(f"`@{twitter.handle}` {verb}tweeted this at <t:{timestamp}:f>: {url}")
|
await channel.send(
|
||||||
|
f"`@{twitter.handle}` {verb}tweeted this at <t:{timestamp}:f>: {url}"
|
||||||
|
)
|
||||||
newest = max(tweets, key=lambda x: x.id)
|
newest = max(tweets, key=lambda x: x.id)
|
||||||
twitter.last_tweet = newest.id
|
twitter.last_tweet = newest.id
|
||||||
twitter.save()
|
twitter.save()
|
||||||
|
@ -79,7 +87,12 @@ class TwitterCog(commands.Cog):
|
||||||
name="follow",
|
name="follow",
|
||||||
description="Follow a Twitter account",
|
description="Follow a Twitter account",
|
||||||
options=[
|
options=[
|
||||||
create_option(name="handle", description="Twitter account", option_type=COptionType.STRING, required=True),
|
create_option(
|
||||||
|
name="handle",
|
||||||
|
description="Twitter account",
|
||||||
|
option_type=COptionType.STRING,
|
||||||
|
required=True,
|
||||||
|
),
|
||||||
create_option(
|
create_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
description="Channel to post tweets into",
|
description="Channel to post tweets into",
|
||||||
|
@ -91,7 +104,10 @@ class TwitterCog(commands.Cog):
|
||||||
description="Mirror re-tweets?",
|
description="Mirror re-tweets?",
|
||||||
option_type=COptionType.STRING,
|
option_type=COptionType.STRING,
|
||||||
required=False,
|
required=False,
|
||||||
choices=[create_choice(name="Yes", value="Yes"), create_choice(name="No", value="No")],
|
choices=[
|
||||||
|
create_choice(name="Yes", value="Yes"),
|
||||||
|
create_choice(name="No", value="No"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -111,7 +127,9 @@ class TwitterCog(commands.Cog):
|
||||||
try:
|
try:
|
||||||
latest_tweet = self.api.user_timeline(screen_name=handle, count=1)[0]
|
latest_tweet = self.api.user_timeline(screen_name=handle, count=1)[0]
|
||||||
except Exception:
|
except Exception:
|
||||||
await ctx.send("Unable to get user timeline. Are you sure the handle is correct?", hidden=True)
|
await ctx.send(
|
||||||
|
"Unable to get user timeline. Are you sure the handle is correct?", hidden=True
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
count = Twitter.objects(guild=ctx.guild.id).count()
|
count = Twitter.objects(guild=ctx.guild.id).count()
|
||||||
|
@ -155,7 +173,9 @@ class TwitterCog(commands.Cog):
|
||||||
option = create_select_option(label=twitter.handle, value=str(twitter.id))
|
option = create_select_option(label=twitter.handle, value=str(twitter.id))
|
||||||
options.append(option)
|
options.append(option)
|
||||||
|
|
||||||
select = create_select(options=options, custom_id="to_delete", min_values=1, max_values=len(twitters))
|
select = create_select(
|
||||||
|
options=options, custom_id="to_delete", min_values=1, max_values=len(twitters)
|
||||||
|
)
|
||||||
|
|
||||||
components = [create_actionrow(select)]
|
components = [create_actionrow(select)]
|
||||||
block = "\n".join(x.handle for x in twitters)
|
block = "\n".join(x.handle for x in twitters)
|
||||||
|
@ -167,7 +187,10 @@ class TwitterCog(commands.Cog):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
context = await wait_for_component(
|
context = await wait_for_component(
|
||||||
self.bot, check=lambda x: ctx.author.id == x.author.id, messages=message, timeout=60 * 5
|
self.bot,
|
||||||
|
check=lambda x: ctx.author.id == x.author.id,
|
||||||
|
messages=message,
|
||||||
|
timeout=60 * 5,
|
||||||
)
|
)
|
||||||
for to_delete in context.selected_options:
|
for to_delete in context.selected_options:
|
||||||
_ = Twitter.objects(guild=ctx.guild.id, id=ObjectId(to_delete)).delete()
|
_ = Twitter.objects(guild=ctx.guild.id, id=ObjectId(to_delete)).delete()
|
||||||
|
@ -175,7 +198,9 @@ class TwitterCog(commands.Cog):
|
||||||
for component in row["components"]:
|
for component in row["components"]:
|
||||||
component["disabled"] = True
|
component["disabled"] = True
|
||||||
block = "\n".join(handlemap[x] for x in context.selected_options)
|
block = "\n".join(handlemap[x] for x in context.selected_options)
|
||||||
await context.edit_origin(content=f"Unfollowed the following:\n```\n{block}\n```", components=components)
|
await context.edit_origin(
|
||||||
|
content=f"Unfollowed the following:\n```\n{block}\n```", components=components
|
||||||
|
)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
for row in components:
|
for row in components:
|
||||||
for component in row["components"]:
|
for component in row["components"]:
|
||||||
|
@ -192,7 +217,10 @@ class TwitterCog(commands.Cog):
|
||||||
description="Mirror re-tweets?",
|
description="Mirror re-tweets?",
|
||||||
option_type=COptionType.STRING,
|
option_type=COptionType.STRING,
|
||||||
required=True,
|
required=True,
|
||||||
choices=[create_choice(name="Yes", value="Yes"), create_choice(name="No", value="No")],
|
choices=[
|
||||||
|
create_choice(name="Yes", value="Yes"),
|
||||||
|
create_choice(name="No", value="No"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -209,7 +237,9 @@ class TwitterCog(commands.Cog):
|
||||||
option = create_select_option(label=twitter.handle, value=str(twitter.id))
|
option = create_select_option(label=twitter.handle, value=str(twitter.id))
|
||||||
options.append(option)
|
options.append(option)
|
||||||
|
|
||||||
select = create_select(options=options, custom_id="to_update", min_values=1, max_values=len(twitters))
|
select = create_select(
|
||||||
|
options=options, custom_id="to_update", min_values=1, max_values=len(twitters)
|
||||||
|
)
|
||||||
|
|
||||||
components = [create_actionrow(select)]
|
components = [create_actionrow(select)]
|
||||||
block = "\n".join(x.handle for x in twitters)
|
block = "\n".join(x.handle for x in twitters)
|
||||||
|
@ -221,7 +251,10 @@ class TwitterCog(commands.Cog):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
context = await wait_for_component(
|
context = await wait_for_component(
|
||||||
self.bot, check=lambda x: ctx.author.id == x.author.id, messages=message, timeout=60 * 5
|
self.bot,
|
||||||
|
check=lambda x: ctx.author.id == x.author.id,
|
||||||
|
messages=message,
|
||||||
|
timeout=60 * 5,
|
||||||
)
|
)
|
||||||
handlemap = {str(x.id): x.handle for x in twitters}
|
handlemap = {str(x.id): x.handle for x in twitters}
|
||||||
for to_update in context.selected_options:
|
for to_update in context.selected_options:
|
||||||
|
@ -233,8 +266,11 @@ class TwitterCog(commands.Cog):
|
||||||
component["disabled"] = True
|
component["disabled"] = True
|
||||||
block = "\n".join(handlemap[x] for x in context.selected_options)
|
block = "\n".join(handlemap[x] for x in context.selected_options)
|
||||||
await context.edit_origin(
|
await context.edit_origin(
|
||||||
content=f"{'Unfollowed' if not retweets else 'Followed'} retweets from the following:"
|
content=(
|
||||||
f"\n```\n{block}\n```",
|
f"{'Unfollowed' if not retweets else 'Followed'} "
|
||||||
|
"retweets from the following:"
|
||||||
|
f"\n```\n{block}\n```"
|
||||||
|
),
|
||||||
components=components,
|
components=components,
|
||||||
)
|
)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|
|
@ -228,7 +228,9 @@ class UtilCog(commands.Cog):
|
||||||
async def _server_info(self, ctx: SlashContext) -> None:
|
async def _server_info(self, ctx: SlashContext) -> None:
|
||||||
guild: Guild = ctx.guild
|
guild: Guild = ctx.guild
|
||||||
|
|
||||||
owner = f"{guild.owner.name}#{guild.owner.discriminator}" if guild.owner else "||`[redacted]`||"
|
owner = (
|
||||||
|
f"{guild.owner.name}#{guild.owner.discriminator}" if guild.owner else "||`[redacted]`||"
|
||||||
|
)
|
||||||
|
|
||||||
region = guild.region
|
region = guild.region
|
||||||
categories = len(guild.categories)
|
categories = len(guild.categories)
|
||||||
|
@ -308,7 +310,9 @@ class UtilCog(commands.Cog):
|
||||||
@cog_ext.cog_slash(
|
@cog_ext.cog_slash(
|
||||||
name="pigpen",
|
name="pigpen",
|
||||||
description="Encode a string into pigpen",
|
description="Encode a string into pigpen",
|
||||||
options=[create_option(name="text", description="Text to encode", option_type=3, required=True)],
|
options=[
|
||||||
|
create_option(name="text", description="Text to encode", option_type=3, required=True)
|
||||||
|
],
|
||||||
)
|
)
|
||||||
async def _pigpen(self, ctx: SlashContext, text: str) -> None:
|
async def _pigpen(self, ctx: SlashContext, text: str) -> None:
|
||||||
outp = "`"
|
outp = "`"
|
||||||
|
|
|
@ -11,7 +11,7 @@ from jarvis.utils import build_embed, find
|
||||||
from jarvis.utils.field import Field
|
from jarvis.utils.field import Field
|
||||||
|
|
||||||
invites = re.compile(
|
invites = re.compile(
|
||||||
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)",
|
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501
|
||||||
flags=re.IGNORECASE,
|
flags=re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class MessageEventHandler(object):
|
||||||
channel = find(lambda x: x.id == 599068193339736096, message.channel_mentions)
|
channel = find(lambda x: x.id == 599068193339736096, message.channel_mentions)
|
||||||
if channel and message.author.id == 293795462752894976:
|
if channel and message.author.id == 293795462752894976:
|
||||||
await channel.send(
|
await channel.send(
|
||||||
content="https://cdn.discordapp.com/attachments/664621130044407838/805218508866453554/tech.gif"
|
content="https://cdn.discordapp.com/attachments/664621130044407838/805218508866453554/tech.gif" # noqa: E501
|
||||||
)
|
)
|
||||||
content = re.sub(r"\s+", "", message.content)
|
content = re.sub(r"\s+", "", message.content)
|
||||||
match = invites.search(content)
|
match = invites.search(content)
|
||||||
|
@ -87,7 +87,9 @@ class MessageEventHandler(object):
|
||||||
name=message.author.nick if message.author.nick else message.author.name,
|
name=message.author.nick if message.author.nick else message.author.name,
|
||||||
icon_url=message.author.avatar_url,
|
icon_url=message.author.avatar_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}" # noqa: E501
|
||||||
|
)
|
||||||
await message.channel.send(embed=embed)
|
await message.channel.send(embed=embed)
|
||||||
|
|
||||||
async def massmention(self, message: Message) -> None:
|
async def massmention(self, message: Message) -> None:
|
||||||
|
@ -99,7 +101,8 @@ class MessageEventHandler(object):
|
||||||
if (
|
if (
|
||||||
massmention
|
massmention
|
||||||
and massmention.value > 0 # noqa: W503
|
and massmention.value > 0 # noqa: W503
|
||||||
and len(message.mentions) - (1 if message.author in message.mentions else 0) # noqa: W503
|
and len(message.mentions) # noqa: W503
|
||||||
|
- (1 if message.author in message.mentions else 0) # noqa: W503
|
||||||
> massmention.value # noqa: W503
|
> massmention.value # noqa: W503
|
||||||
):
|
):
|
||||||
_ = Warning(
|
_ = Warning(
|
||||||
|
@ -120,7 +123,9 @@ class MessageEventHandler(object):
|
||||||
name=message.author.nick if message.author.nick else message.author.name,
|
name=message.author.nick if message.author.nick else message.author.name,
|
||||||
icon_url=message.author.avatar_url,
|
icon_url=message.author.avatar_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}"
|
||||||
|
)
|
||||||
await message.channel.send(embed=embed)
|
await message.channel.send(embed=embed)
|
||||||
|
|
||||||
async def roleping(self, message: Message) -> None:
|
async def roleping(self, message: Message) -> None:
|
||||||
|
@ -188,7 +193,9 @@ class MessageEventHandler(object):
|
||||||
name=message.author.nick if message.author.nick else message.author.name,
|
name=message.author.nick if message.author.nick else message.author.name,
|
||||||
icon_url=message.author.avatar_url,
|
icon_url=message.author.avatar_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}")
|
embed.set_footer(
|
||||||
|
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}"
|
||||||
|
)
|
||||||
await message.channel.send(embed=embed)
|
await message.channel.send(embed=embed)
|
||||||
|
|
||||||
async def on_message(self, message: Message) -> None:
|
async def on_message(self, message: Message) -> None:
|
||||||
|
|
|
@ -16,7 +16,9 @@ async def unban() -> None:
|
||||||
bans = Ban.objects(type="temp", active=True)
|
bans = Ban.objects(type="temp", active=True)
|
||||||
unbans = []
|
unbans = []
|
||||||
for ban in bans:
|
for ban in bans:
|
||||||
if ban.created_at + timedelta(hours=ban.duration) < datetime.utcnow() + timedelta(minutes=10):
|
if ban.created_at + timedelta(hours=ban.duration) < datetime.utcnow() + timedelta(
|
||||||
|
minutes=10
|
||||||
|
):
|
||||||
guild = await jarvis.jarvis.fetch_guild(ban.guild)
|
guild = await jarvis.jarvis.fetch_guild(ban.guild)
|
||||||
user = await jarvis.jarvis.fetch_user(ban.user)
|
user = await jarvis.jarvis.fetch_user(ban.user)
|
||||||
if user:
|
if user:
|
||||||
|
|
|
@ -80,7 +80,7 @@ def get_extensions(path: str = jarvis.cogs.__path__) -> list:
|
||||||
def parse_color_hex(hex: str) -> Color:
|
def parse_color_hex(hex: str) -> Color:
|
||||||
"""Convert a hex color to a d.py Color."""
|
"""Convert a hex color to a d.py Color."""
|
||||||
hex = hex.lstrip("#")
|
hex = hex.lstrip("#")
|
||||||
rgb = tuple(int(hex[i : i + 2], 16) for i in (0, 2, 4)) # noqa: E203
|
rgb = tuple(int(hex[i : i + 2], 16) for i in (0, 2, 4))
|
||||||
return Color.from_rgb(*rgb)
|
return Color.from_rgb(*rgb)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue