Update fun.py
Added shorter !cc deletion message to solve message overflow error
This commit is contained in:
parent
1317783063
commit
50022f6979
31
cogs/fun.py
31
cogs/fun.py
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
@ -86,7 +87,7 @@ class Fun(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
del_notifs[owner.id]['commands'].append((x.name, x.message))
|
del_notifs[owner.id]['commands'].append((x.name, x.message))
|
||||||
|
|
||||||
# x.delete_instance()
|
x.delete_instance()
|
||||||
del_counter += 1
|
del_counter += 1
|
||||||
|
|
||||||
elif x.last_used + timedelta(days=60) < now and (x.sent_warns is None or x.sent_warns == 0):
|
elif x.last_used + timedelta(days=60) < now and (x.sent_warns is None or x.sent_warns == 0):
|
||||||
@ -113,18 +114,40 @@ class Fun(commands.Cog):
|
|||||||
plural = len(del_notifs[member]["commands"]) > 1
|
plural = len(del_notifs[member]["commands"]) > 1
|
||||||
msg_content = f'Yo, it\'s cleanup time. I am deleting the following custom ' \
|
msg_content = f'Yo, it\'s cleanup time. I am deleting the following custom ' \
|
||||||
f'command{"s" if plural else ""}:\n\n'
|
f'command{"s" if plural else ""}:\n\n'
|
||||||
|
short_msg_content = copy.deepcopy(msg_content)
|
||||||
for x in del_notifs[member]["commands"]:
|
for x in del_notifs[member]["commands"]:
|
||||||
msg_content += f'`!cc {x[0]}` - {x[1]}\n'
|
msg_content += f'`!cc {x[0]}` - {x[1]}\n'
|
||||||
await del_notifs[member]['member'].send(msg_content)
|
short_msg_content += f'`!cc {x[0]}`\n'
|
||||||
|
|
||||||
|
try:
|
||||||
|
await del_notifs[member]['member'].send(msg_content)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'fun daily_check - could not send deletion message to {del_notifs[member]["member"]} '
|
||||||
|
f'/ trying short_msg')
|
||||||
|
try:
|
||||||
|
await del_notifs[member]['member'].send(short_msg_content)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'fun daily_check - still could not send deletion message')
|
||||||
|
|
||||||
for member in warn_notifs:
|
for member in warn_notifs:
|
||||||
plural = len(warn_notifs[member]["commands"]) > 1
|
plural = len(warn_notifs[member]["commands"]) > 1
|
||||||
msg_content = f'Heads up, the following custom ' \
|
msg_content = f'Heads up, the following custom ' \
|
||||||
f'command{"s" if plural else ""} will be deleted next month if ' \
|
f'command{"s" if plural else ""} will be deleted next month if ' \
|
||||||
f'{"they are" if plural else "it is"} not used:\n\n'
|
f'{"they are" if plural else "it is"} not used:\n\n'
|
||||||
|
short_msg_content = copy.deepcopy(msg_content)
|
||||||
for x in warn_notifs[member]["commands"]:
|
for x in warn_notifs[member]["commands"]:
|
||||||
msg_content += f'`!cc {x[0]}` - {x[1]}\n'
|
msg_content += f'`!cc {x[0]}` - {x[1]}\n'
|
||||||
await warn_notifs[member]['member'].send(msg_content)
|
short_msg_content += f'`!cc {x[0]}`\n'
|
||||||
|
|
||||||
|
try:
|
||||||
|
await warn_notifs[member]['member'].send(msg_content)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'fun daily_check - could not send warn message to {warn_notifs[member]["member"]} '
|
||||||
|
f'/ trying short_msg')
|
||||||
|
try:
|
||||||
|
await warn_notifs[member]['member'].send(short_msg_content)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'fun daily_check - still could not send warn message')
|
||||||
|
|
||||||
logging.info(f'Deleted {del_counter} commands; sent deletion notifications to {len(del_notifs)} users; '
|
logging.info(f'Deleted {del_counter} commands; sent deletion notifications to {len(del_notifs)} users; '
|
||||||
f'sent warnings to {len(warn_notifs)} users')
|
f'sent warnings to {len(warn_notifs)} users')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user