Skip to content

Plugin readFile error #1269

@Jobians

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

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