Ejemplo n.º 1
0
    async def discord_link_for_ckey(self, ctx, ckey):
        """
        Given a valid ckey, return the latest record linked to that user
        """
        prefix = await self.config.guild(ctx.guild).mysql_prefix()
        query = f"SELECT * FROM {prefix}discord_links WHERE ckey = %s AND discord_id IS NOT NULL ORDER BY timestamp DESC LIMIT 1"
        parameters = [ckey]
        results = await self.query_database(ctx, query, parameters)
        if len(results):
            return DiscordLink.from_db_record(results[0])

        return None
Ejemplo n.º 2
0
 async def all_discord_links_for_ckey(self, ctx, ckey):
     """
     Given a valid ckey, return a list of all the valid records in the discord_links table for this user as discord link records
     ordered by timestamp descending
     """
     prefix = await self.config.guild(ctx.guild).mysql_prefix()
     query = f"SELECT * FROM {prefix}discord_links WHERE ckey = %s AND discord_id IS NOT NULL ORDER BY TIMESTAMP desc"
     parameters = [ckey]
     discord_links = list()
     results = await self.query_database(ctx, query, parameters)
     for result in results:
         discord_links.append(DiscordLink.from_db_record(result))
     return discord_links