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:
commit
33ea412d7a
6 changed files with 82 additions and 20 deletions
|
@ -24,6 +24,9 @@ elif [ "$ID" -eq "arch" ] || [ "$ID" -eq "manjaro" ]; then
|
||||||
pacman -Sy tmux python python-pip
|
pacman -Sy tmux python python-pip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
|
cargo install tokei --features all
|
||||||
|
|
||||||
if [ ! -d "/home/jarvis" ]; then
|
if [ ! -d "/home/jarvis" ]; then
|
||||||
echo Creating user jarvis...
|
echo Creating user jarvis...
|
||||||
useradd -m jarvis
|
useradd -m jarvis
|
||||||
|
|
|
@ -9,13 +9,12 @@ from discord.ext import commands
|
||||||
from discord.ext.tasks import loop
|
from discord.ext.tasks import loop
|
||||||
from discord.utils import find, get
|
from discord.utils import find, get
|
||||||
from discord_slash import SlashCommand
|
from discord_slash import SlashCommand
|
||||||
from psutil import Process
|
|
||||||
|
|
||||||
from jarvis import logo, utils
|
from jarvis import logo, utils
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.db import DBManager
|
from jarvis.utils.db import DBManager
|
||||||
from jarvis.utils.field import Field
|
from jarvis.utils.field import Field
|
||||||
|
from psutil import Process
|
||||||
|
|
||||||
if asyncio.get_event_loop().is_closed():
|
if asyncio.get_event_loop().is_closed():
|
||||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
|
@ -24,6 +23,10 @@ intents = Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
restart_ctx = None
|
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)
|
jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents)
|
||||||
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
|
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(
|
roleping = db.jarvis.settings.find_one(
|
||||||
{"guild": message.guild.id, "setting": "roleping"}
|
{"guild": message.guild.id, "setting": "roleping"}
|
||||||
)
|
)
|
||||||
if roleping and any(
|
roles = []
|
||||||
x.id in roleping["value"] for x in message.role_mentions
|
for mention in message.role_mentions:
|
||||||
):
|
roles.append(mention.id)
|
||||||
await message.delete()
|
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(
|
db.jarvis.warns.insert_one(
|
||||||
{
|
{
|
||||||
"user": message.author.id,
|
"user": message.author.id,
|
||||||
"reason": "Pinged a blocked role",
|
"reason": "Pinged a blocked role/user with a blocked role",
|
||||||
"admin": get_config().client_id,
|
"admin": get_config().client_id,
|
||||||
"time": datetime.now(),
|
"time": datetime.now(),
|
||||||
"guild": message.guild.id,
|
"guild": message.guild.id,
|
||||||
|
@ -143,7 +149,13 @@ async def on_message(message: Message):
|
||||||
"active": True,
|
"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(
|
embed = build_embed(
|
||||||
title="Warning",
|
title="Warning",
|
||||||
description=f"{message.author.mention} has been warned",
|
description=f"{message.author.mention} has been warned",
|
||||||
|
@ -156,7 +168,8 @@ async def on_message(message: Message):
|
||||||
icon_url=message.author.avatar_url,
|
icon_url=message.author.avatar_url,
|
||||||
)
|
)
|
||||||
embed.set_footer(
|
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)
|
await message.channel.send(embed=embed)
|
||||||
autopurge = db.jarvis.autopurge.find_one(
|
autopurge = db.jarvis.autopurge.find_one(
|
||||||
|
@ -164,6 +177,45 @@ async def on_message(message: Message):
|
||||||
)
|
)
|
||||||
if autopurge:
|
if autopurge:
|
||||||
await message.delete(delay=autopurge["delay"])
|
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)
|
await jarvis.process_commands(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,9 @@ class DevCog(commands.Cog):
|
||||||
await self._decode(ctx, method, data)
|
await self._decode(ctx, method, data)
|
||||||
|
|
||||||
async def _cloc(self, ctx):
|
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```")
|
await ctx.send(f"```\n{output}\n```")
|
||||||
|
|
||||||
@commands.command(name="cloc", help="Get J.A.R.V.I.S. lines of code")
|
@commands.command(name="cloc", help="Get J.A.R.V.I.S. lines of code")
|
||||||
|
|
|
@ -2,13 +2,12 @@ import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
import jarvis
|
||||||
import pymongo
|
import pymongo
|
||||||
from discord import DMChannel
|
from discord import DMChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
from discord_slash import SlashContext
|
from discord_slash import SlashContext
|
||||||
|
|
||||||
import jarvis
|
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.db import DBManager
|
from jarvis.utils.db import DBManager
|
||||||
|
@ -45,8 +44,9 @@ class ModlogCog(commands.Cog):
|
||||||
value=f"{admin.mention} ({admin.name}"
|
value=f"{admin.mention} ({admin.name}"
|
||||||
+ f"#{admin.discriminator})",
|
+ 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(
|
embed = build_embed(
|
||||||
title=title,
|
title=title,
|
||||||
description=desc,
|
description=desc,
|
||||||
|
@ -293,6 +293,7 @@ class ModlogCog(commands.Cog):
|
||||||
verified
|
verified
|
||||||
and before.guild.get_role(verified["value"])
|
and before.guild.get_role(verified["value"])
|
||||||
not in before.roles
|
not in before.roles
|
||||||
|
and after.guild.get_role(verified["value"]) in after.roles
|
||||||
):
|
):
|
||||||
embed = await self.process_verify(before, after)
|
embed = await self.process_verify(before, after)
|
||||||
elif before.nick != after.nick:
|
elif before.nick != after.nick:
|
||||||
|
@ -327,6 +328,7 @@ class ModlogCog(commands.Cog):
|
||||||
+ f"#{log.user.discriminator})",
|
+ f"#{log.user.discriminator})",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if log.reason:
|
||||||
fields.append(
|
fields.append(
|
||||||
Field(name="Reason", value=log.reason, inline=False),
|
Field(name="Reason", value=log.reason, inline=False),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,13 +2,12 @@ from datetime import datetime
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
import jarvis
|
||||||
from discord import Message, TextChannel
|
from discord import Message, TextChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
from discord_slash import SlashContext, cog_ext
|
from discord_slash import SlashContext, cog_ext
|
||||||
from discord_slash.utils.manage_commands import create_option
|
from discord_slash.utils.manage_commands import create_option
|
||||||
|
|
||||||
import jarvis
|
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.db import DBManager
|
from jarvis.utils.db import DBManager
|
||||||
|
@ -187,6 +186,9 @@ class StarboardCog(commands.Cog):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
count = self.db.jarvis.stars.find(
|
||||||
|
{"guild": message.guild.id, "starboard": starboard.id}
|
||||||
|
).count()
|
||||||
content = message.content
|
content = message.content
|
||||||
|
|
||||||
attachments = message.attachments
|
attachments = message.attachments
|
||||||
|
@ -200,7 +202,7 @@ class StarboardCog(commands.Cog):
|
||||||
content = "\u200b"
|
content = "\u200b"
|
||||||
|
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Click Here to view context",
|
title=f"[#{count}] Click Here to view context",
|
||||||
description=content,
|
description=content,
|
||||||
fields=[],
|
fields=[],
|
||||||
url=message.jump_url,
|
url=message.jump_url,
|
||||||
|
@ -221,6 +223,7 @@ class StarboardCog(commands.Cog):
|
||||||
|
|
||||||
self.db.jarvis.stars.insert_one(
|
self.db.jarvis.stars.insert_one(
|
||||||
{
|
{
|
||||||
|
"index": count,
|
||||||
"message": message.id,
|
"message": message.id,
|
||||||
"channel": message.channel.id,
|
"channel": message.channel.id,
|
||||||
"guild": message.guild.id,
|
"guild": message.guild.id,
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue