OutwalkStudios / discord-backup

a module for backing up and restoring discord servers.
MIT License
11 stars 11 forks source link

Stage channels still not fixed #24

Closed TuskarMA closed 9 months ago

TuskarMA commented 9 months ago

image Data that i getting from the stage channel in backup

{
 "oldId": "1044145830917046282"
}

error when loading

Job Failed: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
ID: loadChannel::guild.channels.create::undefined
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
    at handleErrors (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:722:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:1120:23)
    at async SequentialHandler.queueRequest (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:953:14)
    at async _REST.request (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:1266:22)
    at async GuildChannelManager.create (C:\Users\V3land\Documents\backup_test\node_modules\discord.js\src\managers\GuildChannelManager.js:171:18) {
  requestBody: {
    files: undefined,
    json: {
      name: undefined,
      topic: undefined,
      type: null,
      nsfw: undefined,
      bitrate: undefined,
      user_limit: undefined,
      parent_id: '1195604545766686761',
      position: undefined,
      permission_overwrites: undefined,
      rate_limit_per_user: undefined,
      rtc_region: undefined,
      video_quality_mode: undefined,
      default_thread_rate_limit_per_user: undefined,
      available_tags: undefined,
      default_reaction_emoji: undefined,
      default_auto_archive_duration: undefined,
      default_sort_order: undefined,
      default_forum_layout: undefined
    }
  },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: { name: [Object] }
  },
  code: 50035,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/guilds/1195297326730842182/channels'
}

npm list

+-- @outwalk/discord-backup@0.7.0
+-- discord.js@14.14.1
+-- dotenv@16.3.1
`-- mongoose@8.0.4
TuskarMA commented 9 months ago

Also, logged child value after

} else if (child.type == discord_js.ChannelType.GuildStageVoice) {

If statement seems to be working, there is a something inside channelData = fetchStageChannelData(child, options, limiter);

Child value

<ref *2> StageChannel {
  type: 13,
  guild: <ref *1> Guild {
    id: '609422663898628110',
    name: 'GTA 5 RP | FIB',
    icon: '453c331fa46fdbd80e9c0ce9916f595d',
    features: [
      'ANIMATED_ICON',
      'INVITE_SPLASH',
      'AUTO_MODERATION',
      'SOUNDBOARD',
      'CHANNEL_ICON_EMOJIS_GENERATED',
      'THREE_DAY_THREAD_ARCHIVE',
      'COMMUNITY',
      'GUESTS_ENABLED',
      'TEXT_IN_VOICE_ENABLED',
      'NEWS'
    ],
    commands: GuildApplicationCommandManager {
      permissions: [ApplicationCommandPermissionsManager],
      guild: [Circular *1]
    },
    members: GuildMemberManager { guild: [Circular *1] },
    channels: GuildChannelManager { guild: [Circular *1] },
    bans: GuildBanManager { guild: [Circular *1] },
    roles: RoleManager { guild: [Circular *1] },
    presences: PresenceManager {},
    voiceStates: VoiceStateManager { guild: [Circular *1] },
    stageInstances: StageInstanceManager { guild: [Circular *1] },
    invites: GuildInviteManager { guild: [Circular *1] },
    scheduledEvents: GuildScheduledEventManager { guild: [Circular *1] },
    autoModerationRules: AutoModerationRuleManager { guild: [Circular *1] },
    available: true,
    shardId: 0,
    splash: null,
    banner: null,
    description: null,
    verificationLevel: 2,
    vanityURLCode: null,
    nsfwLevel: 0,
    premiumSubscriptionCount: 2,
    discoverySplash: null,
    memberCount: 240,
    large: true,
    premiumProgressBarEnabled: false,
    applicationId: null,
    afkTimeout: 900,
    afkChannelId: '629404453589614620',
    systemChannelId: '615288792328175648',
    premiumTier: 1,
    widgetEnabled: null,
    widgetChannelId: null,
    explicitContentFilter: 2,
    mfaLevel: 0,
    joinedTimestamp: 1644335246997,
    defaultMessageNotifications: 1,
    systemChannelFlags: SystemChannelFlagsBitField { bitfield: 0 },
    maximumMembers: 500000,
    maximumPresences: null,
    maxVideoChannelUsers: 25,
    maxStageVideoChannelUsers: 50,
    approximateMemberCount: null,
    approximatePresenceCount: null,
    vanityURLUses: null,
    rulesChannelId: '1043902254266195979',
    publicUpdatesChannelId: '1043902254266195980',
    preferredLocale: 'en-US',
    safetyAlertsChannelId: null,
    ownerId: '204259438163525633',
    emojis: GuildEmojiManager { guild: [Circular *1] },
    stickers: GuildStickerManager { guild: [Circular *1] }
  },
  guildId: '609422663898628110',
  permissionOverwrites: PermissionOverwriteManager { channel: [Circular *2] },
  messages: GuildMessageManager { channel: [Circular *2] },
  nsfw: false,
  flags: ChannelFlagsBitField { bitfield: 0 },
  id: '1044145830917046282',
  name: 'Собрание',
  rawPosition: 3,
  parentId: '695954822242762752',
  rtcRegion: null,
  bitrate: 64000,
  userLimit: 10000,
  videoQualityMode: null,
  lastMessageId: '1189959789887889411',
  rateLimitPerUser: 0,
  topic: null
}
TuskarMA commented 9 months ago

Oh, found the issue. Seems like you forget to add await in

channelData = fetchStageChannelData(child, options, limiter);

I will make PR with this fix. Please, review it. Thank you!

TuskarMA commented 9 months ago

Fixed code still returning error on loading.

Job Failed: Cannot execute action on this channel type
ID: loadChannel::guild.channels.create::Собрание
DiscordAPIError[50024]: Cannot execute action on this channel type
    at handleErrors (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:722:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:1120:23)
    at async SequentialHandler.queueRequest (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:953:14)
    at async _REST.request (C:\Users\V3land\Documents\backup_test\node_modules\@discordjs\rest\dist\index.js:1266:22)
    at async GuildChannelManager.create (C:\Users\V3land\Documents\backup_test\node_modules\discord.js\src\managers\GuildChannelManager.js:171:18) {
  requestBody: {
    files: undefined,
    json: {
      name: 'Собрание',
      topic: null,
      type: 13,
      nsfw: false,
      bitrate: 64000,
      user_limit: 10000,
      parent_id: '1195627558184681553',
      position: undefined,
      permission_overwrites: undefined,
      rate_limit_per_user: 0,
      rtc_region: undefined,
      video_quality_mode: undefined,
      default_thread_rate_limit_per_user: undefined,
      available_tags: undefined,
      default_reaction_emoji: undefined,
      default_auto_archive_duration: undefined,
      default_sort_order: undefined,
      default_forum_layout: undefined
    }
  },
  rawError: {
    message: 'Cannot execute action on this channel type',
    code: 50024
  },
  code: 50024,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/guilds/1195297326730842182/channels'
}
TuskarMA commented 9 months ago

Found the issue. Server must be checked before loading for 'community' feature enabled in config. Need to make additional checks. Also, if community feature enabled, itteration with creating channels fails with error Error occurred while deleting channels: Cannot delete a channel required for community servers Error occurred while deleting channels: Cannot delete a channel required for community servers

jleeson commented 9 months ago

Thanks for catching that @TuskarMA, It sounds like you know the fix for the community checks to add. Do you want to add those checks to your PR or would you like me to add them?

jleeson commented 9 months ago

@TuskarMA, I merged your PR and added the feature check for Community when loading a stage channel as well as added a check that only deletable channels will be attempted to be deleted in clearGuild which should remove those errors you received. All these changes are present in v0.7.1, let me know if you have any more issues. I will leave this issue open until its confirmed everything is working.

jleeson commented 9 months ago

I assume everything is working correctly for you now, I will close this issue, but if there are any remaining problems, I will re-open it.