@ -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 ( mes sa ge : discord . Message ) :
return mes sa ge . author == user and mes sa ge . 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 } " )