Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 2x 2x 2x | import { Config } from "@/modules/shared/config/types";
import { DiscordAPIUrl } from "@/types/Constants";
import { resolveAxiosObservable } from "@/utils/ResolveAxiosObservable";
import { HttpService } from "@nestjs/axios";
import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { AxiosResponse } from "axios";
import { PartialChannelData } from "discord.js";
import { GuildDTO } from "../guild/guild.dto";
import { IDiscordHttpService } from "./interfaces/IDiscordHttpService.interface";
@Injectable()
export class DiscordHttpService implements IDiscordHttpService {
public constructor(
private readonly httpService: HttpService,
private readonly config: ConfigService,
) {}
public async fetchBotGuilds(): Promise<AxiosResponse<GuildDTO[], unknown>> {
return await resolveAxiosObservable<AxiosResponse<GuildDTO[], unknown>>(
this.httpService.get(`${DiscordAPIUrl}/users/@me/guilds`, {
headers: {
Authorization: `Bot ${this.config.getOrThrow<Config["Discord"]>("Discord").Token}`,
},
}),
);
}
public async fetchUserGuilds(accessToken: string): Promise<AxiosResponse<GuildDTO[], unknown>> {
return await resolveAxiosObservable<AxiosResponse<GuildDTO[], unknown>>(
this.httpService.get(`${DiscordAPIUrl}/users/@me/guilds`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
}),
);
}
public async fetchGuildChannels(guildId: string): Promise<AxiosResponse<PartialChannelData, unknown>> {
return await resolveAxiosObservable<AxiosResponse<PartialChannelData, unknown>>(
this.httpService.get(`${DiscordAPIUrl}/guilds/${guildId}/channels`, {
headers: {
Authorization: `Bot ${this.config.getOrThrow<Config["Discord"]>("Discord").Token}`,
},
}),
);
}
}
|