API Reference¶
Logging In¶
Log in with the exact same syntax as the regular coc.py client.
- coc.ext.discordlinks.login(username: str, password: str, loop: Optional[asyncio.events.AbstractEventLoop] = None) coc.ext.discordlinks.DiscordLinkClient ¶
Eases logging into the API client.
For more information on this project, please join the discord server - <discord.gg/Eaja7gJ>
You must have your username and password as given on the server. If unsure as to what this means, please reach out to an admin.
- Parameters
username (str) – Your username as given on the discord server.
password (str) – Your password as given on the discord server
loop (Optional[
asyncio.AbstractEventLoop
]) – Theasyncio.AbstractEventLoop
to use for HTTP requests. Anasyncio.get_event_loop()
will be used ifNone
is passed
Example¶
from coc.ext import discordlinks
client = discordlinks.login("username", "password")
With the returned instance, you can complete any of the operations detailed below.
Discord Link Client¶
The following is a quick and simple overview of all methods available with the links API.
- class coc.ext.discordlinks.DiscordLinkClient(username: str, password: str, loop: Optional[asyncio.events.AbstractEventLoop] = None)¶
An extension that helps interact with the Clash of Clans Discord Junkies’ Discord Links API.
For more information on this project, please join the discord server - <discord.gg/Eaja7gJ>
You must have your username and password as given on the server. If unsure as to what this means, please reach out to an admin.
- Parameters
username (str) – Your username as given on the discord server.
password (str) – Your password as given on the discord server
loop (Optional[
asyncio.AbstractEventLoop
]) – Theasyncio.AbstractEventLoop
to use for HTTP requests. Anasyncio.get_event_loop()
will be used ifNone
is passed
Methods:
add_link
(player_tag, discord_id)Creates a link between a player tag and a discord ID for the shared junkies database.
delete_link
(player_tag)Deletes a link between a player tag and a discord ID for the shared junkies database.
get_link
(player_tag)Get a linked discord ID of a player tag.
get_linked_players
(discord_id)Get a list of player tags linked to a discord ID.
get_links
(*player_tag)Get linked discord IDs for an iterable of player tags.
get_many_linked_players
(*discord_id)Get a linked discord ID of a player tag.
- await add_link(player_tag: str, discord_id: int)¶
Creates a link between a player tag and a discord ID for the shared junkies database. Player tags can be found either in game or by from clan member lists.
- await delete_link(player_tag: str)¶
Deletes a link between a player tag and a discord ID for the shared junkies database.
Player tags can be found either in game or by from clan member lists.
- Parameters
player_tag (str) – The player tag to remove the link from.
- await get_link(player_tag: str) Optional[int] ¶
Get a linked discord ID of a player tag. Player tags can be found either in game or by from clan member lists.
- await get_linked_players(discord_id: int) List[str] ¶
Get a list of player tags linked to a discord ID.
- await get_links(*player_tag: str) List[Tuple[str, Optional[int]]] ¶
Get linked discord IDs for an iterable of player tags. Player tags can be found either in game or by from clan member lists.
This is the recommended method to use when fetching links for multiple tags as it uses a different endpoint.
- Parameters
*player_tag (
str
) – The player tags to search for.- Returns
List[:class:`str` – A list of player_tag, discord_id tuple matches. Discord ID will be
None
if not found.- Return type
, Optional[
int
]]
Example
links = await client.get_links("#tag1", "#tag2", "#tag3") for player_tag, discord_id in links: print(player_tag, discord_id)
- await get_many_linked_players(*discord_id: int) List[Tuple[str, int]] ¶
Get a linked discord ID of a player tag.
This is the recommended method to use when fetching links for multiple IDs as it uses a different endpoint.
- Parameters
*discord_id (
str
) – The discord IDs to search for.- Returns
A list containing (discord_id, tag) matches.
- Return type
Example
links = await client.get_many_linked_players(123456789, 234567890, 345678901) for player_tag, discord_id in links: print("{} is linked to {}".format(discord_id, player_tag))