-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathlanguagematch.py
36 lines (26 loc) · 1.05 KB
/
languagematch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# import.standard
import random
from typing import Any, List
# import.thirdparty
import discord
from discord.ext import commands, tasks
class LanguageMatch(commands.Cog):
""" Class for the language match feature. """
def __init__(self, client: commands.Bot) -> None:
""" Class init method. """
self.client = client
@commands.Cog.listener()
async def on_ready(self) -> None:
print("LanguageMatch cog is ready!")
@tasks.loop(seconds=60)
async def check_end_of_conversation(self) -> None:
""" """
async def get_random_member(self, members: List[discord.Member], filter_fnc: Any) -> discord.Member:
""" Gets a random member from a filter.
:param members: The list of members from which to choose.
:param filter_fnc: The filter to apply to the get. """
filtered_members = list(filter(filter_fnc, members))
return random.choice(filtered_members)
def setup(client: commands.Bot) -> None:
""" Cog's setup function. """
client.add_cog(LanguageMatch(client))