Minor changes and fixes, re-apply temproles after re-join
This commit is contained in:
parent
ec14506634
commit
6c73e0df48
6 changed files with 76 additions and 25 deletions
|
@ -3,7 +3,7 @@ import asyncio
|
|||
|
||||
from aiohttp import ClientSession
|
||||
from beanie.operators import Set
|
||||
from interactions import listen
|
||||
from interactions import listen, Intents
|
||||
from interactions.ext.prefixed_commands.context import PrefixedContext
|
||||
from interactions.models.discord.channel import DMChannel
|
||||
from interactions.models.discord.embed import EmbedField
|
||||
|
@ -28,10 +28,6 @@ class EventMixin(MemberEventMixin, MessageEventMixin, ComponentEventMixin):
|
|||
async def _chunk_all(self) -> None:
|
||||
"""Chunk all guilds."""
|
||||
self.logger.warn("Deprecated function, nothing will happen")
|
||||
# for guild in self.guilds:
|
||||
# if not guild.chunked.is_set():
|
||||
# self.logger.debug(f"Chunking guild {guild.name} <{guild.id}>")
|
||||
# await guild.chunk_guild()
|
||||
|
||||
async def _sync_domains(self) -> None:
|
||||
self.logger.debug("Loading phishing domains")
|
||||
|
@ -176,7 +172,9 @@ class EventMixin(MemberEventMixin, MessageEventMixin, ComponentEventMixin):
|
|||
embed.set_author(
|
||||
name=ctx.author.username, icon_url=ctx.author.display_avatar.url
|
||||
)
|
||||
embed.set_footer(text=f"{ctx.author.user.username} | {ctx.author.id}")
|
||||
embed.set_footer(
|
||||
text=f"{ctx.author.user.username}#{ctx.author.discriminator} | {ctx.author.id}"
|
||||
)
|
||||
if channel:
|
||||
await channel.send(embeds=embed)
|
||||
else:
|
||||
|
|
|
@ -7,7 +7,7 @@ from interactions.client.utils.misc_utils import get
|
|||
from interactions.models.discord.embed import Embed, EmbedField
|
||||
from interactions.models.discord.enums import AuditLogEventType
|
||||
from interactions.models.discord.user import Member
|
||||
from jarvis_core.db.models import Setting
|
||||
from jarvis_core.db.models import Setting, Temprole
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
@ -20,19 +20,41 @@ class MemberEventMixin:
|
|||
"""Handle on_member_add event."""
|
||||
user = event.member
|
||||
guild = event.guild
|
||||
unverified = await Setting.find_one(Setting.guild == guild.id, Setting.setting == "unverified")
|
||||
unverified = await Setting.find_one(
|
||||
Setting.guild == guild.id, Setting.setting == "unverified"
|
||||
)
|
||||
temproles = await Temprole.find(
|
||||
Temprole.guild == guild.id, Temprole.user == user.id
|
||||
).to_list()
|
||||
if unverified:
|
||||
self.logger.debug(f"Applying unverified role to {user.id} in {guild.id}")
|
||||
role = await guild.fetch_role(unverified.value)
|
||||
if role not in user.roles:
|
||||
if not role:
|
||||
self.logger.warn(
|
||||
f"Unverified role no longer exists for guild {guild.id}"
|
||||
)
|
||||
await settings.delete()
|
||||
elif role not in user.roles:
|
||||
await user.add_role(role, reason="User just joined and is unverified")
|
||||
if temproles:
|
||||
self.logger.debug(f"User {user.id} still has temprole(s) in {guild.id}")
|
||||
for temprole in temproles:
|
||||
role = await guild.fetch_role(temprole.role)
|
||||
if not role:
|
||||
await temprole.delete()
|
||||
elif role not in user.roles:
|
||||
await user.add_role(
|
||||
role, reason="User joined and has existing temprole"
|
||||
)
|
||||
|
||||
@listen()
|
||||
async def on_member_remove(self, event: MemberRemove) -> None:
|
||||
"""Handle on_member_remove event."""
|
||||
user = event.member
|
||||
guild = event.guild
|
||||
log = await Setting.find_one(Setting.guild == guild.id, Setting.setting == "activitylog")
|
||||
log = await Setting.find_one(
|
||||
Setting.guild == guild.id, Setting.setting == "activitylog"
|
||||
)
|
||||
if log:
|
||||
self.logger.debug(f"User {user.id} left {guild.id}")
|
||||
channel = await guild.fetch_channel(log.value)
|
||||
|
@ -103,10 +125,7 @@ class MemberEventMixin:
|
|||
|
||||
async def process_rename(self, before: Member, after: Member) -> None:
|
||||
"""Process name change."""
|
||||
if (
|
||||
before.nickname == after.nickname
|
||||
and before.username == after.username
|
||||
):
|
||||
if before.nickname == after.nickname and before.username == after.username:
|
||||
return
|
||||
|
||||
fields = (
|
||||
|
@ -132,21 +151,29 @@ class MemberEventMixin:
|
|||
before = event.before
|
||||
after = event.after
|
||||
|
||||
if (before.display_name == after.display_name and before.roles == after.roles) or (not after or not before):
|
||||
if (
|
||||
before.display_name == after.display_name and before.roles == after.roles
|
||||
) or (not after or not before):
|
||||
return
|
||||
|
||||
log = await Setting.find_one(Setting.guild == before.guild.id, Setting.setting == "activitylog")
|
||||
log = await Setting.find_one(
|
||||
Setting.guild == before.guild.id, Setting.setting == "activitylog"
|
||||
)
|
||||
if log:
|
||||
channel = await before.guild.fetch_channel(log.value)
|
||||
await asyncio.sleep(0.5) # Wait for audit log
|
||||
embed = None
|
||||
if before._role_ids != after._role_ids:
|
||||
verified = await Setting.find_one(Setting.guild == before.guild.id, Setting.setting == "verified")
|
||||
verified = await Setting.find_one(
|
||||
Setting.guild == before.guild.id, Setting.setting == "verified"
|
||||
)
|
||||
v_role = None
|
||||
if verified:
|
||||
v_role = await before.guild.fetch_role(verified.value)
|
||||
if not v_role:
|
||||
self.logger.debug(f"Guild {before.guild.id} verified role no longer exists")
|
||||
self.logger.debug(
|
||||
f"Guild {before.guild.id} verified role no longer exists"
|
||||
)
|
||||
await verified.delete()
|
||||
else:
|
||||
if not before.has_role(v_role) and after.has_role(v_role):
|
||||
|
|
|
@ -132,6 +132,8 @@ class MessageEventMixin:
|
|||
await message.channel.send(embeds=embed)
|
||||
except Exception:
|
||||
self.logger.warn("Failed to send warning embed")
|
||||
if re.match("\b(?!dbrand)([Dd][Bb][Rr][Aa][Nn][Dd])\b", message.content):
|
||||
await message.reply("*dbrand")
|
||||
|
||||
async def filters(self, message: Message) -> None:
|
||||
"""Handle filter evennts."""
|
||||
|
@ -598,7 +600,7 @@ class MessageEventMixin:
|
|||
not ignore or (ignore and message.channel.id not in ignore.value)
|
||||
):
|
||||
try:
|
||||
content = message.content or "N/A"
|
||||
content = message.content or message.system_content or "N/A"
|
||||
except AttributeError:
|
||||
content = "N/A"
|
||||
fields = [EmbedField("Original Message", content, False)]
|
||||
|
|
|
@ -43,7 +43,7 @@ JARVIS_LOGO = Image.open("jarvis_small.png").convert("RGBA")
|
|||
RESPONSES = {
|
||||
264072583987593217: "Oh fuck no, go fuck yourself",
|
||||
840031256201003008: "https://tenor.com/view/fluffy-gabriel-iglesias-you-need-jesus-thats-what-you-need-pointing-up-gif-16385108",
|
||||
215564028615852033: "As flattered as I am, I'm not into bestiality",
|
||||
215564028615852033: "Last time you offered, we ended up playing board games instead. No thanks",
|
||||
256110768724901889: "Haven't you broken me enough already?",
|
||||
196018858455334912: "https://www.youtube.com/watch?v=ye5BuYf8q4o",
|
||||
169641326927806464: "I make it a habit to not get involved with people who use robot camoflauge to hide from me",
|
||||
|
@ -77,6 +77,32 @@ class UtilCog(Extension):
|
|||
|
||||
bot = SlashCommand(name="bot", description="Bot commands")
|
||||
|
||||
@bot.subcommand(
|
||||
sub_cmd_name="donate", sub_cmd_description="Support the development of JARVIS"
|
||||
)
|
||||
async def _donate(self, ctx: SlashContext) -> None:
|
||||
await ctx.send(
|
||||
"""Want to support JARVIS? Donate here:
|
||||
|
||||
https://ko-fi.com/zevaryx
|
||||
|
||||
Tips will be used to pay server costs, and any excess will go to local animal shelters.
|
||||
"""
|
||||
)
|
||||
|
||||
@bot.subcommand(
|
||||
sub_cmd_name="donate", sub_cmd_description="Support the development of JARVIS"
|
||||
)
|
||||
async def _donate(self, ctx: SlashContext) -> None:
|
||||
await ctx.send(
|
||||
"""Want to support JARVIS? Donate here:
|
||||
|
||||
https://ko-fi.com/zevaryx
|
||||
|
||||
Tips will be used to pay server costs, and any excess will go to local animal shelters.
|
||||
"""
|
||||
)
|
||||
|
||||
# @bot.subcommand(sub_cmd_name="sex", sub_cmd_description="Have sex with JARVIS")
|
||||
# async def _sex(self, ctx: SlashContext) -> None:
|
||||
# if ctx.author.id == 264072583987593217:
|
||||
|
|
|
@ -74,7 +74,7 @@ class TagCog(Extension):
|
|||
placeholder="Content to send here",
|
||||
style=TextStyles.PARAGRAPH,
|
||||
custom_id="content",
|
||||
max_length=512,
|
||||
max_length=1024,
|
||||
),
|
||||
],
|
||||
title="Create a new tag!",
|
||||
|
@ -190,7 +190,7 @@ class TagCog(Extension):
|
|||
value=tag.content,
|
||||
style=TextStyles.PARAGRAPH,
|
||||
custom_id="content",
|
||||
max_length=512,
|
||||
max_length=1024,
|
||||
),
|
||||
],
|
||||
title="Edit a tag!",
|
||||
|
|
|
@ -182,9 +182,7 @@ class DbrandCog(Extension):
|
|||
async def _support(self, ctx: InteractionContext) -> None:
|
||||
return await self._db_support_cmd(ctx)
|
||||
|
||||
@db.subcommand(
|
||||
sub_cmd_name="gripcheck", sub_cmd_description="Watch a dbrand grip get thrown"
|
||||
)
|
||||
# @db.subcommand(sub_cmd_name="gripcheck", sub_cmd_description="Watch a dbrand grip get thrown")
|
||||
async def _gripcheck(self, ctx: InteractionContext) -> None:
|
||||
video_url = "https://cdn.discordapp.com/attachments/599068193339736096/890679742263623751/video0.mov"
|
||||
image_url = "https://cdn.discordapp.com/attachments/599068193339736096/890680198306095104/image0.jpg"
|
||||
|
|
Loading…
Add table
Reference in a new issue