fix(moderation): reverted previous changes (they dont work lmao)
This commit is contained in:
parent
d300ba60da
commit
30ea17cfb6
1 changed files with 49 additions and 56 deletions
|
@ -5,7 +5,6 @@
|
||||||
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
||||||
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
@ -1739,65 +1738,59 @@ class Moderation(commands.Cog):
|
||||||
file = await self.ctx.message.attachments[0].read()
|
file = await self.ctx.message.attachments[0].read()
|
||||||
data = sorted(json.loads(file), key=lambda x: x['case'])
|
data = sorted(json.loads(file), key=lambda x: x['case'])
|
||||||
|
|
||||||
async def process_case(case, accepted_types, interaction: discord.Interaction):
|
for case in data:
|
||||||
for case in data:
|
if case['type'] not in accepted_types:
|
||||||
if case['type'] not in accepted_types:
|
continue
|
||||||
|
|
||||||
|
timestamp = round(case['timestamp'] / 1000)
|
||||||
|
|
||||||
|
if case['duration']:
|
||||||
|
try:
|
||||||
|
duration = timedelta(seconds=round(float(case['duration']) / 1000))
|
||||||
|
except OverflowError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
timestamp = round(case['timestamp'] / 1000)
|
if case['resolved']:
|
||||||
|
resolved = 1
|
||||||
|
resolved_by = None
|
||||||
|
resolved_reason = None
|
||||||
|
resolved_timestamp = None
|
||||||
|
if case['changes']:
|
||||||
|
for change in case['changes']:
|
||||||
|
if change['type'] == 'RESOLVE':
|
||||||
|
resolved_by = change['staff']
|
||||||
|
resolved_reason = change['reason']
|
||||||
|
resolved_timestamp = round(change['timestamp'] / 1000)
|
||||||
|
break
|
||||||
|
if resolved_by is None:
|
||||||
|
resolved_by = '?'
|
||||||
|
if resolved_reason is None:
|
||||||
|
resolved_reason = 'Could not get resolve reason during moderation import.'
|
||||||
|
if resolved_timestamp is None:
|
||||||
|
resolved_timestamp = timestamp
|
||||||
|
changes = [
|
||||||
|
{
|
||||||
|
'type': "ORIGINAL",
|
||||||
|
'reason': case['reason'],
|
||||||
|
'user_id': case['executor'],
|
||||||
|
'timestamp': timestamp
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': "RESOLVE",
|
||||||
|
'reason': resolved_reason,
|
||||||
|
'user_id': resolved_by,
|
||||||
|
'timestamp': resolved_timestamp
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
resolved = 0
|
||||||
|
resolved_by = 'NULL'
|
||||||
|
resolved_reason = 'NULL'
|
||||||
|
changes = []
|
||||||
|
|
||||||
if case['duration']:
|
await Moderation.mysql_log(self.cog_instance, self.ctx.guild.id, case['executor'], case['type'], case['target'], 0, duration, case['reason'], timestamp=timestamp, resolved=resolved, resolved_by=resolved_by, resolved_reason=resolved_reason, changes=changes, database=database)
|
||||||
try:
|
|
||||||
duration = timedelta(seconds=round(case['duration']) / 1000)
|
|
||||||
except OverflowError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if case['resolved']:
|
await interaction.edit_original_response(content="Import complete.")
|
||||||
resolved = 1
|
|
||||||
resolved_by = None
|
|
||||||
resolved_reason = None
|
|
||||||
resolved_timestamp = None
|
|
||||||
if case['changes']:
|
|
||||||
for change in case['changes']:
|
|
||||||
if change['type'] == 'RESOLVE':
|
|
||||||
resolved_by = change['staff']
|
|
||||||
resolved_reason = change['reason']
|
|
||||||
resolved_timestamp = round(change['timestamp'] / 1000)
|
|
||||||
break
|
|
||||||
if resolved_by is None:
|
|
||||||
resolved_by = '?'
|
|
||||||
if resolved_reason is None:
|
|
||||||
resolved_reason = 'Could not get resolve reason during moderation import.'
|
|
||||||
if resolved_timestamp is None:
|
|
||||||
resolved_timestamp = timestamp
|
|
||||||
changes = [
|
|
||||||
{
|
|
||||||
'type': "ORIGINAL",
|
|
||||||
'reason': case['reason'],
|
|
||||||
'user_id': case['executor'],
|
|
||||||
'timestamp': timestamp
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': "RESOLVE",
|
|
||||||
'reason': resolved_reason,
|
|
||||||
'user_id': resolved_by,
|
|
||||||
'timestamp': resolved_timestamp
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
resolved = 0
|
|
||||||
resolved_by = 'NULL'
|
|
||||||
resolved_reason = 'NULL'
|
|
||||||
changes = []
|
|
||||||
|
|
||||||
await Moderation.mysql_log(self.cog_instance, self.ctx.guild.id, case['executor'], case['type'], case['target'], 0, duration, case['reason'], timestamp=timestamp, resolved=resolved, resolved_by=resolved_by, resolved_reason=resolved_reason, changes=changes, database=database)
|
|
||||||
|
|
||||||
await interaction.edit_original_response(content="Import complete.")
|
|
||||||
|
|
||||||
async def process_cases(data, accepted_types, interaction):
|
|
||||||
await asyncio.gather(*[process_case(case, accepted_types, interaction) for case in data])
|
|
||||||
|
|
||||||
await process_cases(data, accepted_types, interaction)
|
|
||||||
|
|
||||||
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
|
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
|
||||||
async def import_button_n(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
|
async def import_button_n(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
|
||||||
|
|
Loading…
Reference in a new issue