mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
Added GetGuild graphql query
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
"@metafam/utils": "1.0.0",
|
||||
"bluebird": "3.7.2",
|
||||
"body-parser": "1.19.0",
|
||||
"discord.js": "^12.5.1",
|
||||
"ethers": "4.0.48",
|
||||
"express": "4.17.1",
|
||||
"express-graphql": "0.11.0",
|
||||
|
||||
@@ -73,3 +73,24 @@ export const GetLastQuestCompletionForPlayer = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GetGuild = gql`
|
||||
query GetGuild($guildname: String!) {
|
||||
guild(where: { guildname: { _eq: $guildname } }) {
|
||||
id
|
||||
guildname
|
||||
description
|
||||
discord_invite_url
|
||||
join_button_url
|
||||
logo
|
||||
moloch_address
|
||||
name
|
||||
type
|
||||
website_url
|
||||
guild_accounts {
|
||||
type
|
||||
identifier
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import fetch from 'node-fetch';
|
||||
import Discord from 'discord.js';
|
||||
|
||||
import { CONFIG } from '../../config';
|
||||
import { AccountType_Enum, Player } from '../../lib/autogen/hasura-sdk';
|
||||
import { client } from '../../lib/hasuraClient';
|
||||
import { TriggerPayload } from './types';
|
||||
|
||||
export interface UpdateRole {
|
||||
@@ -27,10 +29,16 @@ export const updateDiscordRole = async (
|
||||
previousRole: oldPlayer?.rank?.toString(),
|
||||
newRole: newRank
|
||||
}
|
||||
// look up guild by guildname = 'metagame' (for now),
|
||||
// then look up guild_account for DISCORD type
|
||||
// will need to create new graphql queries for these (can they be joined into one?)
|
||||
|
||||
// look up guild by guildname = 'metagame' (for now),
|
||||
const metafam = await client.GetGuild({guildname: 'metafam'});
|
||||
|
||||
const discordClient = new Discord.Client();
|
||||
discordClient.login(CONFIG.discordBotToken);
|
||||
|
||||
// todo add jsonb field to guild. { ranks: [] }
|
||||
// populate also.
|
||||
|
||||
|
||||
// call discord API. for each query we'll need serverId, playerId, and roleId
|
||||
// since we don't have roleIds, we'll need to look up the roles in the server
|
||||
@@ -39,5 +47,4 @@ export const updateDiscordRole = async (
|
||||
|
||||
// if there's an oldRank, delete it.
|
||||
// if there's a new rank, add it
|
||||
fetch()
|
||||
};
|
||||
|
||||
@@ -12885,7 +12885,7 @@ dirty-chai@^2.0.1:
|
||||
resolved "https://registry.yarnpkg.com/dirty-chai/-/dirty-chai-2.0.1.tgz#6b2162ef17f7943589da840abc96e75bda01aff3"
|
||||
integrity sha512-ys79pWKvDMowIDEPC6Fig8d5THiC0DJ2gmTeGzVAoEH18J8OzLud0Jh7I9IWg3NSk8x2UocznUuFmfHCXYZx9w==
|
||||
|
||||
discord.js@12.5.1, discord.js@^12.2.0:
|
||||
discord.js@12.5.1, discord.js@^12.2.0, discord.js@^12.5.1:
|
||||
version "12.5.1"
|
||||
resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-12.5.1.tgz#992b45753e3815526a279914ccc281d3496f5990"
|
||||
integrity sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==
|
||||
|
||||
Reference in New Issue
Block a user