Skip to content

Commit

Permalink
fix: use discord-api-types
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Aug 9, 2023
1 parent 632d9ac commit e676188
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/api/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ import {
type RESTPostAPIGuildsMFAResult,
type RESTPostAPIGuildsResult,
type RESTPutAPIGuildBanJSONBody,
type RESTPutAPIGuildOnboardingJSONBody,
type RESTPutAPIGuildOnboardingResult,
type RESTPutAPIGuildTemplateSyncResult,
type Snowflake,
} from 'discord-api-types/v10';
Expand Down Expand Up @@ -1252,15 +1254,13 @@ export class GuildsAPI {
*/
public async editOnboarding(
guildId: Snowflake,
body: any,
// body: RESTPutAPIGuildOnboardingJSONBody,
body: RESTPutAPIGuildOnboardingJSONBody,
{ reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {},
) {
return this.rest.put(Routes.guildOnboarding(guildId), {
reason,
body,
signal,
}) as Promise<any>;
// }) as Promise<RESTPutAPIGuildOnboardingResult>;
}) as Promise<RESTPutAPIGuildOnboardingResult>;
}
}
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<GuildOnboarding>}
*/
async editOnboarding(options) {
const newData = await this.client.rest.put(`/guilds/${this.id}/onboarding`, {
const newData = await this.client.rest.put(Routes.guildOnboarding(this.id), {
body: {
prompts: options.prompts.map(prompt => ({
title: prompt.title,
Expand Down
3 changes: 1 addition & 2 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ import {
APIGuildOnboardingPrompt,
APIGuildOnboardingPromptOption,
GuildOnboardingPromptType,
GuildOnboardingMode,
} from 'discord-api-types/v10';
import { ChildProcess } from 'node:child_process';
import { EventEmitter } from 'node:events';
Expand Down Expand Up @@ -1578,8 +1579,6 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
public valueOf(): string;
}

type GuildOnboardingMode = any;

export class GuildOnboarding extends Base {
private constructor(client: Client, data: RESTGetAPIGuildOnboardingResult);
public get guild(): Guild;
Expand Down
34 changes: 34 additions & 0 deletions test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Client, GatewayIntentBits } from './packages/discord.js/src/index.js';

const client = new Client({
intents: GatewayIntentBits.Guilds,
});

client.on('ready', async () => {
console.log('Ready!');

const guild = client.guilds.cache.get('505181778718228480');

const onboarding = await guild.fetchOnboarding();

console.log(onboarding);

const newOnboarding = await guild.editOnboarding({
// enabled: true,
// mode: GuildOnboardingMode.OnboardingAdvanced,

defaultChannels: [
'969941543337218088',
'969941501415153674',
'969941431227658310',
'1003418048260231209',
'1020724886848671856',
'1020725777857257555',
'1088171977312849921',
],
});

console.log(newOnboarding);
});

await client.login();

0 comments on commit e676188

Please sign in to comment.