Merge branch 'v1.0.0' into 'main'

Admin Updates

See merge request stark-industries/j.a.r.v.i.s.!7
This commit is contained in:
Zeva Rose 2021-07-15 20:37:26 +00:00
commit 33ea412d7a
6 changed files with 82 additions and 20 deletions

View file

@ -24,6 +24,9 @@ elif [ "$ID" -eq "arch" ] || [ "$ID" -eq "manjaro" ]; then
pacman -Sy tmux python python-pip
fi
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
cargo install tokei --features all
if [ ! -d "/home/jarvis" ]; then
echo Creating user jarvis...
useradd -m jarvis

View file

@ -9,13 +9,12 @@ from discord.ext import commands
from discord.ext.tasks import loop
from discord.utils import find, get
from discord_slash import SlashCommand
from psutil import Process
from jarvis import logo, utils
from jarvis.config import get_config
from jarvis.utils import build_embed
from jarvis.utils.db import DBManager
from jarvis.utils.field import Field
from psutil import Process
if asyncio.get_event_loop().is_closed():
asyncio.set_event_loop(asyncio.new_event_loop())
@ -24,6 +23,10 @@ intents = Intents.default()
intents.members = True
restart_ctx = None
invites = re.compile(
r"(https?://)?(www.)?(discord.(gg|io|me|li)|discordapp.com/invite)/([^\s/]+?)(?=\b)"
)
jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents)
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
@ -128,14 +131,17 @@ async def on_message(message: Message):
roleping = db.jarvis.settings.find_one(
{"guild": message.guild.id, "setting": "roleping"}
)
if roleping and any(
x.id in roleping["value"] for x in message.role_mentions
):
await message.delete()
roles = []
for mention in message.role_mentions:
roles.append(mention.id)
for mention in message.mentions:
for role in mention.roles:
roles.append(role.id)
if roleping and any(x.id in roleping["value"] for x in roles):
db.jarvis.warns.insert_one(
{
"user": message.author.id,
"reason": "Pinged a blocked role",
"reason": "Pinged a blocked role/user with a blocked role",
"admin": get_config().client_id,
"time": datetime.now(),
"guild": message.guild.id,
@ -143,7 +149,13 @@ async def on_message(message: Message):
"active": True,
}
)
fields = [Field("Reason", "Pinged a blocked role", False)]
fields = [
Field(
"Reason",
"Pinged a blocked role/user with a blocked role",
False,
)
]
embed = build_embed(
title="Warning",
description=f"{message.author.mention} has been warned",
@ -156,7 +168,8 @@ async def on_message(message: Message):
icon_url=message.author.avatar_url,
)
embed.set_footer(
text=f"{message.author.name}#{message.author.discriminator} | {message.author.id}"
text=f"{message.author.name}#{message.author.discriminator} "
+ f"| {message.author.id}"
)
await message.channel.send(embed=embed)
autopurge = db.jarvis.autopurge.find_one(
@ -164,6 +177,45 @@ async def on_message(message: Message):
)
if autopurge:
await message.delete(delay=autopurge["delay"])
matches = invites.match(message.content)
if matches:
if matches.group(5) not in ["dbrand", "VtgZntXcnZ"]:
await message.delete()
db.jarvis.warns.insert_one(
{
"user": message.author.id,
"reason": "Sent an invite link",
"admin": get_config().client_id,
"time": datetime.now(),
"guild": message.guild.id,
"duration": 24,
"active": True,
}
)
fields = [
Field(
"Reason",
"Sent an invite link",
False,
)
]
embed = build_embed(
title="Warning",
description=f"{message.author.mention} has been warned",
fields=fields,
)
embed.set_author(
name=message.author.nick
if message.author.nick
else message.author.name,
icon_url=message.author.avatar_url,
)
embed.set_footer(
text=f"{message.author.name}#"
+ f"{message.author.discriminator} "
+ f"| {message.author.id}"
)
await message.channel.send(embed=embed)
await jarvis.process_commands(message)

View file

@ -280,7 +280,9 @@ class DevCog(commands.Cog):
await self._decode(ctx, method, data)
async def _cloc(self, ctx):
output = subprocess.check_output(["cloc", "."]).decode("UTF-8")
output = subprocess.check_output(
["tokei", "-C", "--sort", "code"]
).decode("UTF-8")
await ctx.send(f"```\n{output}\n```")
@commands.command(name="cloc", help="Get J.A.R.V.I.S. lines of code")

View file

@ -2,13 +2,12 @@ import asyncio
from datetime import datetime, timedelta
import discord
import jarvis
import pymongo
from discord import DMChannel
from discord.ext import commands
from discord.utils import find
from discord_slash import SlashContext
import jarvis
from jarvis.config import get_config
from jarvis.utils import build_embed
from jarvis.utils.db import DBManager
@ -45,8 +44,9 @@ class ModlogCog(commands.Cog):
value=f"{admin.mention} ({admin.name}"
+ f"#{admin.discriminator})",
),
Field(name="Reason", value=log.reason, inline=False),
]
if log.reason:
fields.append(Field(name="Reason", value=log.reason, inline=False))
embed = build_embed(
title=title,
description=desc,
@ -293,6 +293,7 @@ class ModlogCog(commands.Cog):
verified
and before.guild.get_role(verified["value"])
not in before.roles
and after.guild.get_role(verified["value"]) in after.roles
):
embed = await self.process_verify(before, after)
elif before.nick != after.nick:
@ -327,6 +328,7 @@ class ModlogCog(commands.Cog):
+ f"#{log.user.discriminator})",
)
)
if log.reason:
fields.append(
Field(name="Reason", value=log.reason, inline=False),
)

View file

@ -2,13 +2,12 @@ from datetime import datetime
import aiohttp
import discord
import jarvis
from discord import Message, TextChannel
from discord.ext import commands
from discord.utils import find
from discord_slash import SlashContext, cog_ext
from discord_slash.utils.manage_commands import create_option
import jarvis
from jarvis.config import get_config
from jarvis.utils import build_embed
from jarvis.utils.db import DBManager
@ -187,6 +186,9 @@ class StarboardCog(commands.Cog):
)
return
count = self.db.jarvis.stars.find(
{"guild": message.guild.id, "starboard": starboard.id}
).count()
content = message.content
attachments = message.attachments
@ -200,7 +202,7 @@ class StarboardCog(commands.Cog):
content = "\u200b"
embed = build_embed(
title="Click Here to view context",
title=f"[#{count}] Click Here to view context",
description=content,
fields=[],
url=message.jump_url,
@ -221,6 +223,7 @@ class StarboardCog(commands.Cog):
self.db.jarvis.stars.insert_one(
{
"index": count,
"message": message.id,
"channel": message.channel.id,
"guild": message.guild.id,

File diff suppressed because one or more lines are too long