Browse Source

опа неихуя

huy
gsd 2 years ago
parent
commit
0530d14134
  1. 2
      other_ext/register.py
  2. 37
      other_ext/webhook_helper.py

2
other_ext/register.py

@ -82,7 +82,7 @@ class Extension:
@core.listen()
async def on_message(message: discord.Message):
if message.guild.id != core.main_server_id:
if not message.guild or message.guild.id != core.main_server_id:
return
if message.channel.id != self.auth_channel:

37
other_ext/webhook_helper.py

@ -1,3 +1,4 @@
from email import message
from discord.ext import tasks, commands
import discord
import asyncio
@ -44,31 +45,35 @@ class Extension:
return
@core.listen()
async def on_reaction_add(reaction: discord.Reaction, user: discord.User):
print(reaction.emoji, reaction.message.webhook_id, reaction.me, reaction.message.guild.get_member(user.id).get_role(self.track_role_id))
async def on_raw_reaction_add(payload):
channel = await self.core.fetch_channel(payload.channel_id)
message: discord.Message = await channel.fetch_message(payload.message_id)
user: discord.User = await self.core.fetch_user(payload.user_id)
if reaction.message.webhook_id != self.track_webhook_id:
print(payload.emoji, message.webhook_id, self.core.user.id == payload.user_id, message.guild.get_member(user.id).get_role(self.track_role_id))
if message.webhook_id != self.track_webhook_id:
return
if reaction.me:
if self.core.user.id == payload.user_id:
return
if not reaction.message.guild.get_member(user.id).get_role(self.track_role_id):
if not message.guild.get_member(user.id).get_role(self.track_role_id):
return
if str(reaction.emoji) in self.webhook_reaction_translate.keys():
executor, kwargs = self.webhook_reaction_translate[str(reaction.emoji)]
if str(payload.emoji) in self.webhook_reaction_translate.keys():
executor, kwargs = self.webhook_reaction_translate[str(payload.emoji)]
if "requester" in kwargs:
kwargs["requester"] = user.id
if "reason" in kwargs and not user.id in self.no_reason:
def check(message: discord.Message):
return message.author == user and message.channel == reaction.message.channel
def check(msg: discord.Message):
return msg.author == user and msg.channel == message.channel
try:
req_msg = await reaction.message.channel.send(content=f"{user.mention}!\nВведи причину отправив сообщение")
req_msg = await message.channel.send(content=f"{user.mention}!\nВведи причину отправив сообщение")
msg = await self.core.wait_for("message", timeout=60.0, check=check)
except asyncio.TimeoutError:
await reaction.message.channel.send(content=f"{user.mention}!\nДействие {reaction.emoji} отменено спустя время", delete_after=60)
await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} отменено спустя время", delete_after=60)
return
try:
@ -78,16 +83,16 @@ class Extension:
#не ну это пиздец
if msg.content.split(" ") > 0 and msg.content.lower().split(" ")[0] == "отмена":
return await reaction.message.channel.send(content=f"{user.mention}!\nДействие {reaction.emoji} отменено по твоей воле", delete_after=60)
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} отменено по твоей воле", delete_after=60)
else:
kwargs["reason"] = msg.content
if "reason" in kwargs and user.id in self.no_reason:
kwargs["reason"] = self.no_reason[user.id]
del self.no_reason[user.id]
if "profile" in kwargs:
kwargs["profile"] = reaction.message.embeds[0].url
kwargs["profile"] = message.embeds[0].url
if "requester_profile" in kwargs:
kwargs["profile"] = reaction.message.embeds[0].author.url
kwargs["profile"] = message.embeds[0].author.url
try:
if type(executor) == str:
@ -96,9 +101,9 @@ class Extension:
result = await executor(**kwargs)
except Exception as err:
traceback.print_exc()
return await reaction.message.channel.send(content=f"{user.mention}!\nДействие {reaction.emoji} невозможно из-за ошибки: {err}. Стоит написать добродею!", delete_after=60)
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} невозможно из-за ошибки: {err}. Стоит написать добродею!", delete_after=60)
return await reaction.message.channel.send(content=f"{user.mention}!\nДействие {reaction.emoji} дало ответ: {result}")
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} дало ответ: {result}")

Loading…
Cancel
Save