Skip to content

Plugin readFile error #1269

Description

@Jobians

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Image

async readFile(encoding) {
      if (segments.length === 4 && segments[0] === 'bots' && segments[2] === 'commands') {
        const { botId, commandId } = resolvePath();
        const command = await apiRequest(`/bots/${botId}/commands/${commandId}`);

        if (!command) throw new Error(`Command not found: ${commandId}`);

        let code = command.code;
        const encoder = new TextEncoder();
        const arrayBuffer = encoder.encode(code);  // Convert string to ArrayBuffer (UTF-8)


        if (encoding) {
          // If encoding is provided, decode the file content
          if (encodings?.decode) {
            const decoded = await encodings.decode(code, encoding);
            if (decoded) return decoded;
          }

          // If no specific decoding method is found, use a fallback
          return helpers.decodeText(code, encoding);
        }
        
        return arrayBuffer;
      }

      throw new Error('Not a file or unsupported path');
    },

Environment

957

If applicable, add mockups / screenshots regarding your vision

No response

If applicable, attach your Acode.log file to this issue.

No response

Activity

  1. UnschooledGamer commented on Apr 19, 2025

    @UnschooledGamer
    Collaborator

    Hey @Jobians , Your Issue seems incomplete, Kindly make it more informative.

  2. Jobians commented on Apr 19, 2025

    @Jobians
    ContributorAuthor

    @UnschooledGamer check the screenshot

  3. converted this issue into a discussion #1270 on Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions