import type { Chanel } from "@/data/guild/Channel"; import type { Guild } from "@/data/guild/Guild"; import type { InviteLink } from "@/data/InviteLink"; import { useEventQueuStore } from "@/stores/eventQueu"; import { useUserStore } from "@/stores/user"; import axios from "./axiosConfig"; function getMutualGuilds(): Promise { return new Promise((resolve, reject) => { const userStore = useUserStore(); axios .get("/guild/mutual", { headers: { authorization: `Bearer ${userStore.token}`, }, }) .then((value) => { console.log(value); resolve(value.data); }) .catch((reason) => { console.error(`Fail to get mutal guilds !`); if (reason?.response.status != 401) { const eventQueuStore = useEventQueuStore(); eventQueuStore.push({ uuid: undefined, type: "error", text: "Fail to retrive guilds !", }); } reject(reason); }); }); } function getInviteLink(): Promise { return new Promise((resolve, reject) => { const userStore = useUserStore(); axios .get("/guild/inviteLink", { headers: { authorization: `Bearer ${userStore.token}`, }, }) .then((value) => { console.log(value); resolve(value.data); }) .catch((reason) => { console.error(`Fail to get Invite !`); const eventQueuStore = useEventQueuStore(); eventQueuStore.push({ uuid: undefined, type: "error", text: "Fail to retrive invite link !", }); reject(reason); }); }); } function getTextChannels(guildId: string): Promise { return new Promise((resolve, reject) => { const userStore = useUserStore(); axios .get(`/guild/${guildId}/textChannels`, { headers: { authorization: `Bearer ${userStore.token}`, }, }) .then((value) => { resolve(value.data); }) .catch((reason) => { console.error(`Fail to get text channels !`); const eventQueuStore = useEventQueuStore(); eventQueuStore.push({ uuid: undefined, type: "error", text: "Fail to retrive text channels!", }); reject(reason); }); }); } function getVoiceChannels(guildId: string): Promise { return new Promise((resolve, reject) => { const userStore = useUserStore(); axios .get(`/guild/${guildId}/voiceChannels`, { headers: { authorization: `Bearer ${userStore.token}`, }, }) .then((value) => { resolve(value.data); }) .catch((reason) => { console.error(`Fail to get text channels !`); const eventQueuStore = useEventQueuStore(); eventQueuStore.push({ uuid: undefined, type: "error", text: "Fail to retrive voice channels!", }); reject(reason); }); }); } function getRoles(guildId: string): Promise { return new Promise((resolve, reject) => { const userStore = useUserStore(); axios .get(`/guild/${guildId}/roles`, { headers: { authorization: `Bearer ${userStore.token}`, }, }) .then((value) => { resolve(value.data); }) .catch((reason) => { console.error(`Fail to get roles !`); const eventQueuStore = useEventQueuStore(); eventQueuStore.push({ uuid: undefined, type: "error", text: "Fail to retrive roles!", }); reject(reason); }); }); } export { getMutualGuilds, getInviteLink, getTextChannels, getVoiceChannels, getRoles, };