Skip to content

Commit

Permalink
feat: Add username attribute (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina authored Aug 16, 2023
1 parent 1fc6fb0 commit 7c07ee5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/adaptors/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import type { User, Connection } from "../services/patch-members";

export const withDiscordRepository =
<T>(token: string): Cont.ContT<T, Promise.PromiseHkt, Repository> =>
async (repoUser: (repo: Repository) => Promise<T>): Promise<T> => {
const repo = newRepo(token);
const result = await repoUser(repo);
await revoke(token);
return result;
};
async (repoUser: (repo: Repository) => Promise<T>): Promise<T> => {
const repo = newRepo(token);
const result = await repoUser(repo);
await revoke(token);
return result;
};

const DISCORD_API = "https://discord.com/api/v10";

Expand Down
1 change: 1 addition & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export const checkAssociationLink = (link: {

export interface Member {
discordId: string;
username: string;
associatedLinks: AssociatedLink[];
}
2 changes: 2 additions & 0 deletions src/services/patch-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type Member, checkAssociationLink } from "../models";

export interface User {
id: string;
username: string;
}
export interface Connection {
id: string;
Expand All @@ -28,6 +29,7 @@ export const patchMembers = async (

const member = {
discordId: me.id,
username: me.username,
associatedLinks: connections
.map(({ type, id, name }) => ({ type, id, name }))
.filter(checkAssociationLink),
Expand Down

0 comments on commit 7c07ee5

Please sign in to comment.