<commit_before>import asyncio
import threading
import time
from datetime import timedelta

# noinspection PyPackageRequirements
from discord import PrivacyLevel, EntityType, EventStatus
# noinspection PyPackageRequirements
from discord.utils import utcnow
# noinspection PyPackageRequirements
from discord.ext.commands import Bot

from minqlx import Plugin

import schedule


async def create_and_start_event(bot: Bot):
    event_name = Plugin.get_cvar("qlx_discord_ext_event_name")
    for scheduled_event in bot.guilds[0].scheduled_events:
        if event_name in scheduled_event.name and scheduled_event.status == EventStatus.active:
            return

    event_location = Plugin.get_cvar("qlx_discord_ext_event_location")
    start_date = utcnow() + timedelta(seconds=1)
    end_date = utcnow() + timedelta(hours=6)
    await bot.guilds[0].create_scheduled_event(
        name=event_name, privacy_level=PrivacyLevel.guild_only, start_time=start_date, end_time=end_date,
        entity_type=EntityType.external,
        location=event_location)


async def end_event(bot: Bot):
    event_name = Plugin.get_cvar("qlx_discord_ext_event_name")
    end_date = utcnow() + timedelta(seconds=2)
    for scheduled_event in bot.guilds[0].scheduled_events:
        if event_name in scheduled_event.name and scheduled_event.status == EventStatus.active:
            await scheduled_event.edit(
                name=scheduled_event.name,
                description=scheduled_event.description,
                end_time=end_date,
                privacy_level=scheduled_event.privacy_level,
                entity_type=EntityType.external,
                status=EventStatus.active,
                location=scheduled_event.location)
<commit_msg>scheduled_event.end() for external events finally got fixed, so we can use that coroutine now<commit_after>import asyncio
import threading
import time
from datetime import timedelta

# noinspection PyPackageRequirements
from discord import PrivacyLevel, EntityType, EventStatus
# noinspection PyPackageRequirements
from discord.utils import utcnow
# noinspection PyPackageRequirements
from discord.ext.commands import Bot

from minqlx import Plugin

import schedule


async def create_and_start_event(bot: Bot):
    event_name = Plugin.get_cvar("qlx_discord_ext_event_name")
    for scheduled_event in bot.guilds[0].scheduled_events:
        if event_name in scheduled_event.name and scheduled_event.status == EventStatus.active:
            return

    event_location = Plugin.get_cvar("qlx_discord_ext_event_location")
    start_date = utcnow() + timedelta(seconds=1)
    end_date = utcnow() + timedelta(hours=8)
    await bot.guilds[0].create_scheduled_event(
        name=event_name, privacy_level=PrivacyLevel.guild_only, start_time=start_date, end_time=end_date,
        entity_type=EntityType.external,
        location=event_location)


async def end_event(bot: Bot):
    event_name = Plugin.get_cvar("qlx_discord_ext_event_name")
    end_events = []
    for scheduled_event in bot.guilds[0].scheduled_events:
        if event_name in scheduled_event.name and scheduled_event.status == EventStatus.active:
            end_events.append(scheduled_event.end())

    await asyncio.gather(*end_events)

{'fraction_non_alphanumeric': 0.07085643869377696, 'fraction_numerical': 0.0033887861983980284, 'mean_word_length': 4.271103896103896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6194368', 'n_tokens_mistral': 997, 'n_tokens_neox': 966, 'n_words': 203}